Skip to content

Commit

Permalink
erase election immediately on confirmation
Browse files Browse the repository at this point in the history
We need to keep teh current cleanup loop, because elctions can timeout / be cancelled / ...
  • Loading branch information
gr0vity committed Dec 4, 2024
1 parent 45c3045 commit 33cd2bf
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion nano/node/active_elections.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<nano::election> (node, block_a, nullptr, observe_rep_cb, election_behavior_a);
auto confirmation_action_l = [this, root = root] (std::shared_ptr<nano::block> const & winner_a) {
// Immediately erase the election when confirmed
erase (root);
};
result.election = nano::make_shared<nano::election> (node, block_a, confirmation_action_l, observe_rep_cb, election_behavior_a);
roots.get<tag_root> ().emplace (entry{ root, result.election, std::move (erased_callback_a) });
node.vote_router.connect (hash, result.election);

Expand Down

0 comments on commit 33cd2bf

Please sign in to comment.