Moved h32 hash type from hpfs to util. (#204)

This commit is contained in:
Ravin Perera
2020-12-23 21:58:49 +05:30
committed by GitHub
parent c25ebe66f4
commit f97d7de530
19 changed files with 98 additions and 98 deletions

View File

@@ -33,9 +33,9 @@ namespace msg::fbuf
/**
* Returns hash from Flat Buffer vector of bytes.
*/
hpfs::h32 flatbuff_bytes_to_hash(const flatbuffers::Vector<uint8_t> *buffer)
util::h32 flatbuff_bytes_to_hash(const flatbuffers::Vector<uint8_t> *buffer)
{
return *reinterpret_cast<const hpfs::h32 *>(buffer->data());
return *reinterpret_cast<const util::h32 *>(buffer->data());
}
/**
@@ -87,9 +87,9 @@ namespace msg::fbuf
* Returns Flatbuffer bytes vector from hash.
*/
const flatbuffers::Offset<flatbuffers::Vector<uint8_t>>
hash_to_flatbuff_bytes(flatbuffers::FlatBufferBuilder &builder, const hpfs::h32 hash)
hash_to_flatbuff_bytes(flatbuffers::FlatBufferBuilder &builder, const util::h32 hash)
{
return builder.CreateVector(reinterpret_cast<const uint8_t *>(&hash), sizeof(hpfs::h32));
return builder.CreateVector(reinterpret_cast<const uint8_t *>(&hash), sizeof(util::h32));
}
/**

View File

@@ -2,7 +2,7 @@
#define _HP_MSG_FBUF_COMMON_HELPERS_
#include "../../pchheader.hpp"
#include "../../hpfs/h32.hpp"
#include "../../util/h32.hpp"
#include "common_schema_generated.h"
namespace msg::fbuf
@@ -19,7 +19,7 @@ namespace msg::fbuf
std::string_view flatbuff_str_to_sv(const flatbuffers::String *buffer);
hpfs::h32 flatbuff_bytes_to_hash(const flatbuffers::Vector<uint8_t> *buffer);
util::h32 flatbuff_bytes_to_hash(const flatbuffers::Vector<uint8_t> *buffer);
const std::set<std::string>
flatbuf_bytearrayvector_to_stringlist(const flatbuffers::Vector<flatbuffers::Offset<ByteArray>> *fbvec);
@@ -36,7 +36,7 @@ namespace msg::fbuf
sv_to_flatbuff_str(flatbuffers::FlatBufferBuilder &builder, std::string_view sv);
const flatbuffers::Offset<flatbuffers::Vector<uint8_t>>
hash_to_flatbuff_bytes(flatbuffers::FlatBufferBuilder &builder, hpfs::h32 hash);
hash_to_flatbuff_bytes(flatbuffers::FlatBufferBuilder &builder, util::h32 hash);
const flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<ByteArray>>>
stringlist_to_flatbuf_bytearrayvector(flatbuffers::FlatBufferBuilder &builder, const std::set<std::string> &set);

View File

@@ -3,7 +3,7 @@
#include "../../crypto.hpp"
#include "../../util/util.hpp"
#include "../../hplog.hpp"
#include "../../hpfs/h32.hpp"
#include "../../util/h32.hpp"
#include "../../hpfs/hpfs.hpp"
#include "../../unl.hpp"
#include "p2pmsg_container_generated.h"
@@ -508,7 +508,7 @@ namespace msg::fbuf::p2pmsg
*/
void create_msg_from_fsentry_response(
flatbuffers::FlatBufferBuilder &container_builder, const std::string_view path,
std::vector<hpfs::child_hash_node> &hash_nodes, hpfs::h32 expected_hash, std::string_view lcl)
std::vector<hpfs::child_hash_node> &hash_nodes, util::h32 expected_hash, std::string_view lcl)
{
flatbuffers::FlatBufferBuilder builder(1024);
@@ -540,12 +540,12 @@ namespace msg::fbuf::p2pmsg
*/
void create_msg_from_filehashmap_response(
flatbuffers::FlatBufferBuilder &container_builder, std::string_view path,
std::vector<hpfs::h32> &hashmap, std::size_t file_length, hpfs::h32 expected_hash, std::string_view lcl)
std::vector<util::h32> &hashmap, std::size_t file_length, util::h32 expected_hash, std::string_view lcl)
{
// todo:get a average propsal message size and allocate content builder based on that.
flatbuffers::FlatBufferBuilder builder(1024);
std::string_view hashmap_sv(reinterpret_cast<const char *>(hashmap.data()), hashmap.size() * sizeof(hpfs::h32));
std::string_view hashmap_sv(reinterpret_cast<const char *>(hashmap.data()), hashmap.size() * sizeof(util::h32));
const flatbuffers::Offset<File_HashMap_Response> resp =
CreateFile_HashMap_Response(

View File

@@ -3,7 +3,7 @@
#include "../../pchheader.hpp"
#include "../../p2p/p2p.hpp"
#include "../../hpfs/h32.hpp"
#include "../../util/h32.hpp"
#include "../../hpfs/hpfs.hpp"
#include "p2pmsg_container_generated.h"
#include "p2pmsg_content_generated.h"
@@ -67,11 +67,11 @@ namespace msg::fbuf::p2pmsg
void create_msg_from_fsentry_response(
flatbuffers::FlatBufferBuilder &container_builder, const std::string_view path,
std::vector<hpfs::child_hash_node> &hash_nodes, hpfs::h32 expected_hash, std::string_view lcl);
std::vector<hpfs::child_hash_node> &hash_nodes, util::h32 expected_hash, std::string_view lcl);
void create_msg_from_filehashmap_response(
flatbuffers::FlatBufferBuilder &container_builder, std::string_view path,
std::vector<hpfs::h32> &hashmap, std::size_t file_length, hpfs::h32 expected_hash, std::string_view lcl);
std::vector<util::h32> &hashmap, std::size_t file_length, util::h32 expected_hash, std::string_view lcl);
void create_msg_from_block_response(flatbuffers::FlatBufferBuilder &container_builder, p2p::block_response &block_resp, std::string_view lcl);