Skip to content

Commit

Permalink
Avoid bootstrap notifications from live traffic
Browse files Browse the repository at this point in the history
  • Loading branch information
pwojcikdev committed Mar 6, 2024
1 parent 42544be commit 275c34d
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions nano/node/bootstrap_ascending/service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,26 @@ nano::bootstrap_ascending::service::service (nano::node_config & config_a, nano:
scoring{ config.bootstrap_ascending, config.network_params.network },
database_limiter{ config.bootstrap_ascending.database_requests_limit, 1.0 }
{
// TODO: This is called from a very congested blockprocessor thread. Offload this work to a dedicated processing thread
block_processor.batch_processed.add ([this] (auto const & batch) {
bool should_notify = false;
{
nano::lock_guard<nano::mutex> lock{ mutex };

auto transaction = ledger.store.tx_begin_read ();
for (auto const & [result, context] : batch)
{
debug_assert (context.block != nullptr);
inspect (transaction, result, *context.block);
// Do not try to unnecessarily bootstrap live traffic chains
if (context.source == nano::block_source::bootstrap)
{
release_assert (context.block != nullptr);
inspect (transaction, result, *context.block);
should_notify = true;
}
}
}

condition.notify_all ();
if (should_notify)
{
condition.notify_all ();
}
});
}

Expand Down

0 comments on commit 275c34d

Please sign in to comment.