Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove count byte from confirm_req by hash #2046

Merged
merged 3 commits into from May 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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;
};
}