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

Push front blocks from unchecked #2565

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions nano/node/blockprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void nano::block_processor::add (std::shared_ptr<nano::block> block_a, uint64_t
add (info);
}

void nano::block_processor::add (nano::unchecked_info const & info_a)
void nano::block_processor::add (nano::unchecked_info const & info_a, bool push_front_preference)
wezrule marked this conversation as resolved.
Show resolved Hide resolved
{
if (!nano::work_validate (info_a.block->root (), info_a.block->block_work ()))
{
Expand All @@ -77,10 +77,18 @@ void nano::block_processor::add (nano::unchecked_info const & info_a)
nano::lock_guard<std::mutex> lock (mutex);
if (blocks_filter.find (filter_hash) == blocks_filter.end ())
{
bool quarter_full ((blocks.size () + state_blocks.size () + forced.size ()) > node.flags.block_processor_full_size / 4);
if (info_a.verified == nano::signature_verification::unknown && (info_a.block->type () == nano::block_type::state || info_a.block->type () == nano::block_type::open || !info_a.account.is_zero ()))
{
state_blocks.push_back (info_a);
}
else if (push_front_preference && !quarter_full)
{
/* Push blocks from unchecked to front of processing deque to keep more operations with unchecked inside of single write transaction.
It's designed to help with realtime blocks traffic if block processor is not performing large task like bootstrap.
If deque is a quarter full then push back to allow other blocks processing. */
blocks.push_front (info_a);
}
else
{
blocks.push_back (info_a);
Expand Down Expand Up @@ -560,7 +568,7 @@ void nano::block_processor::queue_unchecked (nano::write_transaction const & tra
--node.ledger.cache.unchecked_count;
}
}
add (info);
add (info, true);
}
node.gap_cache.erase (hash_a);
}
Expand Down
2 changes: 1 addition & 1 deletion nano/node/blockprocessor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class block_processor final
size_t size ();
bool full ();
bool half_full ();
void add (nano::unchecked_info const &);
void add (nano::unchecked_info const &, bool = false);
void add (std::shared_ptr<nano::block>, uint64_t = 0);
void force (std::shared_ptr<nano::block>);
void wait_write ();
Expand Down