Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bound the growth of election_winner_details set #4720

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Notify about vacancy change
  • Loading branch information
pwojcikdev committed Sep 5, 2024
commit d631c02ac0c6494ea043e0ce359356b005a5e9e3
16 changes: 11 additions & 5 deletions nano/node/active_elections.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,14 +193,19 @@ void nano::active_elections::add_election_winner_details (nano::block_hash const

std::shared_ptr<nano::election> nano::active_elections::remove_election_winner_details (nano::block_hash const & hash_a)
{
nano::lock_guard<nano::mutex> guard{ election_winner_details_mutex };
std::shared_ptr<nano::election> result;
auto existing = election_winner_details.find (hash_a);
if (existing != election_winner_details.end ())
{
result = existing->second;
election_winner_details.erase (existing);
nano::lock_guard<nano::mutex> guard{ election_winner_details_mutex };
auto existing = election_winner_details.find (hash_a);
if (existing != election_winner_details.end ())
{
result = existing->second;
election_winner_details.erase (existing);
}
}

vacancy_update ();

return result;
}

Expand Down Expand Up @@ -344,6 +349,7 @@ void nano::active_elections::cleanup_election (nano::unique_lock<nano::mutex> &
{
entry.erased_callback (election);
}

vacancy_update ();

for (auto const & [hash, block] : blocks_l)
Expand Down