diff --git a/nano/node/active_elections.cpp b/nano/node/active_elections.cpp index bd29634bb2..c30615863f 100644 --- a/nano/node/active_elections.cpp +++ b/nano/node/active_elections.cpp @@ -408,7 +408,11 @@ nano::election_insertion_result nano::active_elections::insert (std::shared_ptr< // Representative is defined as online if replying to live votes or rep_crawler queries node.online_reps.observe (rep_a); }; - result.election = nano::make_shared (node, block_a, nullptr, observe_rep_cb, election_behavior_a); + auto confirmation_action_l = [this, root = root] (std::shared_ptr const & winner_a) { + // Immediately erase the election when confirmed + erase (root); + }; + result.election = nano::make_shared (node, block_a, confirmation_action_l, observe_rep_cb, election_behavior_a); roots.get ().emplace (entry{ root, result.election, std::move (erased_callback_a) }); node.vote_router.connect (hash, result.election);