From c3c7b92805f2ad1def650c99fde93f09b40164b8 Mon Sep 17 00:00:00 2001 From: Wesley Shillingford Date: Thu, 23 Jul 2020 11:18:44 +0100 Subject: [PATCH] Unnecessary frontier_get read IO when processing state block root forks (#2848) --- nano/node/node.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/nano/node/node.cpp b/nano/node/node.cpp index 2ab421f2..7f8858b9 100644 --- a/nano/node/node.cpp +++ b/nano/node/node.cpp @@ -527,14 +527,18 @@ void nano::node::process_fork (nano::transaction const & transaction_a, std::sha if (ledger_block && !block_confirmed_or_being_confirmed (transaction_a, ledger_block->hash ()) && (ledger.can_vote (transaction_a, *ledger_block) || modified_a < nano::seconds_since_epoch () - 300 || !block_arrival.recent (block_a->hash ()))) { std::weak_ptr this_w (shared_from_this ()); - auto election = active.insert (ledger_block, boost::none, [this_w, root](std::shared_ptr) { + auto election = active.insert (ledger_block, boost::none, [this_w, root, root_block_type = block_a->type ()](std::shared_ptr) { if (auto this_l = this_w.lock ()) { auto attempt (this_l->bootstrap_initiator.current_attempt ()); if (attempt && attempt->mode == nano::bootstrap_mode::legacy) { auto transaction (this_l->store.tx_begin_read ()); - auto account (this_l->ledger.store.frontier_get (transaction, root)); + nano::account account{ 0 }; + if (root_block_type == nano::block_type::receive || root_block_type == nano::block_type::send || root_block_type == nano::block_type::change || root_block_type == nano::block_type::open) + { + account = this_l->ledger.store.frontier_get (transaction, root); + } if (!account.is_zero ()) { this_l->bootstrap_initiator.connections->requeue_pull (nano::pull_info (account, root, root, attempt->incremental_id));