diff --git a/nano/node/active_transactions.cpp b/nano/node/active_transactions.cpp index b7cc9449..5646cce5 100644 --- a/nano/node/active_transactions.cpp +++ b/nano/node/active_transactions.cpp @@ -1050,9 +1050,8 @@ bool nano::active_transactions::update_difficulty_impl (nano::active_transaction return error; } -bool nano::active_transactions::restart (nano::transaction const & transaction_a, std::shared_ptr const & block_a) +void nano::active_transactions::restart (nano::transaction const & transaction_a, std::shared_ptr const & block_a) { - bool error = true; auto hash (block_a->hash ()); auto ledger_block (node.store.block_get (transaction_a, hash)); if (ledger_block != nullptr && ledger_block->block_work () != block_a->block_work () && !node.block_confirmed_or_being_confirmed (transaction_a, hash)) @@ -1069,17 +1068,14 @@ bool nano::active_transactions::restart (nano::transaction const & transaction_a // Restart election for the upgraded block, previously dropped from elections if (node.ledger.dependents_confirmed (transaction_a, *ledger_block)) { + node.stats.inc (nano::stat::type::election, nano::stat::detail::election_restart); auto previous_balance = node.ledger.balance (transaction_a, ledger_block->previous ()); - auto insert_result = insert (ledger_block, previous_balance); - if (insert_result.inserted) - { - error = false; - node.stats.inc (nano::stat::type::election, nano::stat::detail::election_restart); - } + auto block_has_account = ledger_block->type () == nano::block_type::state || ledger_block->type () == nano::block_type::open; + auto account = block_has_account ? ledger_block->account () : ledger_block->sideband ().account; + activate (account); } } } - return error; } double nano::active_transactions::normalized_multiplier (nano::block const & block_a, boost::optional const & root_it_a) const diff --git a/nano/node/active_transactions.hpp b/nano/node/active_transactions.hpp index 395d36f6..6a0ca47c 100644 --- a/nano/node/active_transactions.hpp +++ b/nano/node/active_transactions.hpp @@ -172,7 +172,7 @@ public: // Returns false if the election difficulty was updated bool update_difficulty (std::shared_ptr const &, bool); // Returns false if the election was restarted - bool restart (nano::transaction const &, std::shared_ptr const &); + void restart (nano::transaction const &, std::shared_ptr const &); // Returns a list of elections sorted by difficulty std::vector> list_active (size_t = std::numeric_limits::max ()); double normalized_multiplier (nano::block const &, boost::optional const & = boost::none) const; diff --git a/nano/node/blockprocessor.cpp b/nano/node/blockprocessor.cpp index 553467d7..1a0ca87d 100644 --- a/nano/node/blockprocessor.cpp +++ b/nano/node/blockprocessor.cpp @@ -553,8 +553,9 @@ nano::process_return nano::block_processor::process_one (nano::write_transaction void nano::block_processor::process_old (nano::transaction const & transaction_a, std::shared_ptr const & block_a, nano::block_origin const origin_a) { + node.active.restart (transaction_a, block_a); // First try to update election difficulty, then attempt to restart an election - if (!node.active.update_difficulty (block_a, true) || !node.active.restart (transaction_a, block_a)) + if (!node.active.update_difficulty (block_a, true)) { // Let others know about the difficulty update if (origin_a == nano::block_origin::local)