Merging block work validity checks in to an early-return pattern.
This commit is contained in:
parent
6d7e63670c
commit
f12f5d54fb
2 changed files with 22 additions and 20 deletions
|
|
@ -208,8 +208,17 @@ void nano::bulk_pull_client::received_block (boost::system::error_code const & e
|
|||
{
|
||||
nano::bufferstream stream (connection->receive_buffer->data (), size_a);
|
||||
auto block (nano::deserialize_block (stream, type_a));
|
||||
if (block != nullptr && !connection->node->network_params.work.validate_entry (*block))
|
||||
if (block != nullptr)
|
||||
{
|
||||
if (connection->node->network_params.work.validate_entry (*block))
|
||||
{
|
||||
if (connection->node->config.logging.bulk_pull_logging ())
|
||||
{
|
||||
connection->node->logger.try_log (boost::str (boost::format ("Insufficient work for bulk pull block: %1%") % block->hash ().to_string ()));
|
||||
}
|
||||
connection->node->stats.inc_detail_only (nano::stat::type::error, nano::stat::detail::insufficient_work);
|
||||
return;
|
||||
}
|
||||
auto hash (block->hash ());
|
||||
if (connection->node->config.logging.bulk_pull_logging ())
|
||||
{
|
||||
|
|
@ -256,7 +265,7 @@ void nano::bulk_pull_client::received_block (boost::system::error_code const & e
|
|||
connection->connections.pool_connection (connection);
|
||||
}
|
||||
}
|
||||
else if (block == nullptr)
|
||||
else
|
||||
{
|
||||
if (connection->node->config.logging.bulk_pull_logging ())
|
||||
{
|
||||
|
|
@ -264,14 +273,6 @@ void nano::bulk_pull_client::received_block (boost::system::error_code const & e
|
|||
}
|
||||
connection->node->stats.inc (nano::stat::type::bootstrap, nano::stat::detail::bulk_pull_deserialize_receive_block, nano::stat::dir::in);
|
||||
}
|
||||
else // Work invalid
|
||||
{
|
||||
if (connection->node->config.logging.bulk_pull_logging ())
|
||||
{
|
||||
connection->node->logger.try_log (boost::str (boost::format ("Insufficient work for bulk pull block: %1%") % block->hash ().to_string ()));
|
||||
}
|
||||
connection->node->stats.inc_detail_only (nano::stat::type::error, nano::stat::detail::insufficient_work);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -233,25 +233,26 @@ void nano::bulk_push_server::received_block (boost::system::error_code const & e
|
|||
{
|
||||
nano::bufferstream stream (receive_buffer->data (), size_a);
|
||||
auto block (nano::deserialize_block (stream, type_a));
|
||||
if (block != nullptr && !connection->node->network_params.work.validate_entry (*block))
|
||||
if (block != nullptr)
|
||||
{
|
||||
if (connection->node->network_params.work.validate_entry (*block))
|
||||
{
|
||||
if (connection->node->config.logging.bulk_pull_logging ())
|
||||
{
|
||||
connection->node->logger.try_log (boost::str (boost::format ("Insufficient work for bulk push block: %1%") % block->hash ().to_string ()));
|
||||
}
|
||||
connection->node->stats.inc_detail_only (nano::stat::type::error, nano::stat::detail::insufficient_work);
|
||||
return;
|
||||
}
|
||||
connection->node->process_active (std::move (block));
|
||||
throttled_receive ();
|
||||
}
|
||||
else if (block == nullptr)
|
||||
else
|
||||
{
|
||||
if (connection->node->config.logging.bulk_pull_logging ())
|
||||
{
|
||||
connection->node->logger.try_log ("Error deserializing block received from pull request");
|
||||
}
|
||||
}
|
||||
else // Work invalid
|
||||
{
|
||||
if (connection->node->config.logging.bulk_pull_logging ())
|
||||
{
|
||||
connection->node->logger.try_log (boost::str (boost::format ("Insufficient work for bulk push block: %1%") % block->hash ().to_string ()));
|
||||
}
|
||||
connection->node->stats.inc_detail_only (nano::stat::type::error, nano::stat::detail::insufficient_work);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue