Internally check if the block processor needs to drop blocks, rather than making it a requirement of the caller. (#4161)

Adds a stat counter when the block_processor drops a block as this is new behavior.
This commit is contained in:
clemahieu 2023-02-28 23:17:52 +00:00 committed by GitHub
commit 81a2ab4f26
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -97,6 +97,11 @@ void nano::block_processor::add (std::shared_ptr<nano::block> const & block_a)
void nano::block_processor::add (nano::unchecked_info const & info_a) void nano::block_processor::add (nano::unchecked_info const & info_a)
{ {
if (full ())
{
node.stats.inc (nano::stat::type::blockprocessor, nano::stat::detail::drop);
return;
}
auto const & block = info_a.block; auto const & block = info_a.block;
debug_assert (!node.network_params.work.validate_entry (*block)); debug_assert (!node.network_params.work.validate_entry (*block));
if (block->type () == nano::block_type::state || block->type () == nano::block_type::open) if (block->type () == nano::block_type::state || block->type () == nano::block_type::open)
@ -115,6 +120,11 @@ void nano::block_processor::add (nano::unchecked_info const & info_a)
void nano::block_processor::add_local (nano::unchecked_info const & info_a) void nano::block_processor::add_local (nano::unchecked_info const & info_a)
{ {
if (full ())
{
node.stats.inc (nano::stat::type::blockprocessor, nano::stat::detail::drop);
return;
}
debug_assert (!node.network_params.work.validate_entry (*info_a.block)); debug_assert (!node.network_params.work.validate_entry (*info_a.block));
state_block_signature_verification.add ({ info_a.block }); state_block_signature_verification.add ({ info_a.block });
} }