Skip to content

Commit

Permalink
Remove count byte from confirm_req by hash (nanocurrency#2046)
Browse files Browse the repository at this point in the history
Use header extensions count instead
  • Loading branch information
SergiySW committed May 30, 2019
1 parent c836738 commit 13138b9
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 9 deletions.
9 changes: 2 additions & 7 deletions nano/node/common.cpp
Expand Up @@ -582,10 +582,6 @@ void nano::confirm_req::serialize (nano::stream & stream_a) const
if (header.block_type () == nano::block_type::not_a_block)
{
assert (!roots_hashes.empty ());
// Calculate size
assert (roots_hashes.size () <= 32);
auto count = static_cast<uint8_t> (roots_hashes.size ());
write (stream_a, count);
// Write hashes & roots
for (auto & root_hash : roots_hashes)
{
Expand All @@ -608,8 +604,7 @@ bool nano::confirm_req::deserialize (nano::stream & stream_a, nano::block_unique
{
if (header.block_type () == nano::block_type::not_a_block)
{
uint8_t count (0);
read (stream_a, count);
uint8_t count (header.count_get ());
for (auto i (0); i != count && !result; ++i)
{
nano::block_hash block_hash (0);
Expand Down Expand Up @@ -677,7 +672,7 @@ size_t nano::confirm_req::size (nano::block_type type_a, size_t count)
}
else if (type_a == nano::block_type::not_a_block)
{
result = sizeof (uint8_t) + count * (sizeof (nano::uint256_union) + sizeof (nano::block_hash));
result = count * (sizeof (nano::uint256_union) + sizeof (nano::block_hash));
}
return result;
}
Expand Down
2 changes: 1 addition & 1 deletion nano/node/network.cpp
Expand Up @@ -322,7 +322,7 @@ void nano::network::broadcast_confirm_req_batch (std::unordered_map<std::shared_
auto j (request_bundle_a.begin ());
count++;
std::vector<std::pair<nano::block_hash, nano::block_hash>> roots_hashes;
// Limit max request size hash + root to 6 pairs
// Limit max request size hash + root to 7 pairs
while (roots_hashes.size () <= confirm_req_hashes_max && !j->second.empty ())
{
roots_hashes.push_back (j->second.back ());
Expand Down
2 changes: 1 addition & 1 deletion nano/node/network.hpp
Expand Up @@ -173,6 +173,6 @@ class network final
std::function<void(std::shared_ptr<nano::transport::channel>)> channel_observer;
static unsigned const broadcast_interval_ms = 10;
static size_t const buffer_size = 512;
static size_t const confirm_req_hashes_max = 6;
static size_t const confirm_req_hashes_max = 7;
};
}

0 comments on commit 13138b9

Please sign in to comment.