Erase lowest priority accounts first

This commit is contained in:
Piotr Wójcik 2024-11-02 15:59:50 +01:00
commit bbfb7debb2
2 changed files with 9 additions and 9 deletions

View file

@ -483,11 +483,11 @@ enum class detail
next_frontier, next_frontier,
blocking_insert, blocking_insert,
blocking_erase_overflow, blocking_overflow,
priority_insert, priority_insert,
priority_erase_by_threshold, priority_erase_by_threshold,
priority_erase_by_blocking, priority_erase_by_blocking,
priority_erase_overflow, priority_overflow,
deprioritize, deprioritize,
deprioritize_failed, deprioritize_failed,
sync_dependencies, sync_dependencies,

View file

@ -212,17 +212,17 @@ void nano::bootstrap::account_sets::dependency_update (nano::block_hash const &
void nano::bootstrap::account_sets::trim_overflow () void nano::bootstrap::account_sets::trim_overflow ()
{ {
while (priorities.size () > config.priorities_max) while (!priorities.empty () && priorities.size () > config.priorities_max)
{ {
// Erase the oldest entry // Erase the lowest priority entry
priorities.pop_front (); stats.inc (nano::stat::type::bootstrap_account_sets, nano::stat::detail::priority_overflow);
stats.inc (nano::stat::type::bootstrap_account_sets, nano::stat::detail::priority_erase_overflow); priorities.get<tag_priority> ().erase (std::prev (priorities.get<tag_priority> ().end ()));
} }
while (blocking.size () > config.blocking_max) while (!blocking.empty () && blocking.size () > config.blocking_max)
{ {
// Erase the oldest entry // Erase the lowest priority entry
stats.inc (nano::stat::type::bootstrap_account_sets, nano::stat::detail::blocking_overflow);
blocking.pop_front (); blocking.pop_front ();
stats.inc (nano::stat::type::bootstrap_account_sets, nano::stat::detail::blocking_erase_overflow);
} }
} }