From 5a66e7ea1ef2ec6d76d56896ece9eee5d7944c5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Wo=CC=81jcik?= <3044353+pwojcikdev@users.noreply.github.com> Date: Mon, 18 Nov 2024 19:41:20 +0100 Subject: [PATCH] Fix priority threshold --- nano/core_test/bootstrap.cpp | 2 +- nano/node/bootstrap/account_sets.cpp | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/nano/core_test/bootstrap.cpp b/nano/core_test/bootstrap.cpp index ec30708ebf..ccebd97cd4 100644 --- a/nano/core_test/bootstrap.cpp +++ b/nano/core_test/bootstrap.cpp @@ -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) diff --git a/nano/node/bootstrap/account_sets.cpp b/nano/node/bootstrap/account_sets.cpp index 98d705dbdd..d73d314ae0 100644 --- a/nano/node/bootstrap/account_sets.cpp +++ b/nano/node/bootstrap/account_sets.cpp @@ -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 ().erase (it); } else { - priorities.get ().modify (it, [] (auto & val) { + priorities.get ().modify (it, [priority] (auto & val) { val.fails += 1; + val.priority = priority; }); } }