diff --git a/nano/node/active_transactions.cpp b/nano/node/active_transactions.cpp index f2f5515bca..d0bfa55267 100644 --- a/nano/node/active_transactions.cpp +++ b/nano/node/active_transactions.cpp @@ -349,14 +349,14 @@ void nano::active_transactions::request_confirm (nano::unique_lock } } -void nano::active_transactions::cleanup_election (nano::unique_lock & lock_a, nano::election const & election) +void nano::active_transactions::cleanup_election (nano::unique_lock & lock_a, std::shared_ptr election) { debug_assert (lock_a.owns_lock ()); - if (!election.confirmed ()) + if (!election->confirmed ()) { node.stats.inc (nano::stat::type::election, nano::stat::detail::election_drop_all); - if (election.behavior == election_behavior::hinted) + if (election->behavior == election_behavior::hinted) { node.stats.inc (nano::stat::type::election, nano::stat::detail::election_hinted_drop); } @@ -364,18 +364,18 @@ void nano::active_transactions::cleanup_election (nano::unique_lock else { node.stats.inc (nano::stat::type::election, nano::stat::detail::election_confirmed_all); - if (election.behavior == election_behavior::hinted) + if (election->behavior == election_behavior::hinted) { node.stats.inc (nano::stat::type::election, nano::stat::detail::election_hinted_confirmed); } } - if (election.behavior == election_behavior::hinted) + if (election->behavior == election_behavior::hinted) { --active_hinted_elections_count; } - auto blocks_l = election.blocks (); + auto blocks_l = election->blocks (); for (auto const & [hash, block] : blocks_l) { auto erased (blocks.erase (hash)); @@ -383,25 +383,25 @@ void nano::active_transactions::cleanup_election (nano::unique_lock debug_assert (erased == 1); erase_inactive_votes_cache (hash); } - roots.get ().erase (roots.get ().find (election.qualified_root)); + roots.get ().erase (roots.get ().find (election->qualified_root)); lock_a.unlock (); vacancy_update (); for (auto const & [hash, block] : blocks_l) { // Notify observers about dropped elections & blocks lost confirmed elections - if (!election.confirmed () || hash != election.winner ()->hash ()) + if (!election->confirmed () || hash != election->winner ()->hash ()) { node.observers.active_stopped.notify (hash); } - if (!election.confirmed ()) + if (!election->confirmed ()) { // Clear from publish filter node.network.publish_filter.clear (block); } } - node.logger.try_log (boost::str (boost::format ("Election erased for root %1%, confirmed: %2$b") % election.qualified_root.to_string () % election.confirmed ())); + node.logger.try_log (boost::str (boost::format ("Election erased for root %1%, confirmed: %2$b") % election->qualified_root.to_string () % election->confirmed ())); } std::vector> nano::active_transactions::list_active (std::size_t max_a) @@ -1045,7 +1045,7 @@ void nano::active_transactions::erase (nano::qualified_root const & root_a) auto root_it (roots.get ().find (root_a)); if (root_it != roots.get ().end ()) { - cleanup_election (lock, *root_it->election); + cleanup_election (lock, root_it->election); } } @@ -1063,7 +1063,7 @@ void nano::active_transactions::erase_oldest () { node.stats.inc (nano::stat::type::election, nano::stat::detail::election_drop_overflow); auto item = roots.get ().front (); - cleanup_election (lock, *item.election); + cleanup_election (lock, item.election); } } diff --git a/nano/node/active_transactions.hpp b/nano/node/active_transactions.hpp index 0cfbbdb1d8..163da42cfc 100644 --- a/nano/node/active_transactions.hpp +++ b/nano/node/active_transactions.hpp @@ -233,7 +233,7 @@ class active_transactions final void request_confirm (nano::unique_lock &); void erase (nano::qualified_root const &); // Erase all blocks from active and, if not confirmed, clear digests from network filters - void cleanup_election (nano::unique_lock & lock_a, nano::election const &); + void cleanup_election (nano::unique_lock & lock_a, std::shared_ptr); // Returns a list of elections sorted by difficulty, mutex must be locked std::vector> list_active_impl (std::size_t) const;