Skip to content

Commit

Permalink
Fix priority threshold
Browse files Browse the repository at this point in the history
  • Loading branch information
pwojcikdev committed Dec 10, 2024
1 parent b927ce9 commit 5a66e7e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion nano/core_test/bootstrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ TEST (account_sets, priority_up_down)
sets.priority_up (account);
ASSERT_EQ (sets.priority (account), nano::bootstrap::account_sets::priority_initial);
sets.priority_down (account);
ASSERT_EQ (sets.priority (account), nano::bootstrap::account_sets::priority_initial);
ASSERT_EQ (sets.priority (account), nano::bootstrap::account_sets::priority_initial / nano::bootstrap::account_sets::priority_divide);
}

TEST (account_sets, priority_down_empty)
Expand Down
7 changes: 5 additions & 2 deletions nano/node/bootstrap/account_sets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,18 @@ void nano::bootstrap::account_sets::priority_down (nano::account const & account
{
stats.inc (nano::stat::type::bootstrap_account_sets, nano::stat::detail::deprioritize);

if (it->fails >= account_sets::max_fails || it->fails >= it->priority)
auto priority = it->priority / account_sets::priority_divide;

if (it->fails >= account_sets::max_fails || it->fails >= it->priority || priority <= account_sets::priority_cutoff)
{
stats.inc (nano::stat::type::bootstrap_account_sets, nano::stat::detail::erase_by_threshold);
priorities.get<tag_account> ().erase (it);
}
else
{
priorities.get<tag_account> ().modify (it, [] (auto & val) {
priorities.get<tag_account> ().modify (it, [priority] (auto & val) {
val.fails += 1;
val.priority = priority;
});
}
}
Expand Down

0 comments on commit 5a66e7e

Please sign in to comment.