diff --git a/nano/core_test/toml.cpp b/nano/core_test/toml.cpp index edb1e9226c..744e70acd8 100644 --- a/nano/core_test/toml.cpp +++ b/nano/core_test/toml.cpp @@ -275,6 +275,7 @@ TEST (toml, daemon_config_deserialize_defaults) ASSERT_EQ (conf.node.hinted_scheduler.hinting_threshold_percent, defaults.node.hinted_scheduler.hinting_threshold_percent); ASSERT_EQ (conf.node.hinted_scheduler.check_interval.count (), defaults.node.hinted_scheduler.check_interval.count ()); ASSERT_EQ (conf.node.hinted_scheduler.block_cooldown.count (), defaults.node.hinted_scheduler.block_cooldown.count ()); + ASSERT_EQ (conf.node.hinted_scheduler.vacancy_threshold_percent, defaults.node.hinted_scheduler.vacancy_threshold_percent); ASSERT_EQ (conf.node.vote_cache.max_size, defaults.node.vote_cache.max_size); ASSERT_EQ (conf.node.vote_cache.max_voters, defaults.node.vote_cache.max_voters); @@ -543,6 +544,7 @@ TEST (toml, daemon_config_deserialize_no_defaults) hinting_threshold = 99 check_interval = 999 block_cooldown = 999 + vacancy_threshold = 99 [node.rocksdb] enable = true @@ -720,6 +722,7 @@ TEST (toml, daemon_config_deserialize_no_defaults) ASSERT_NE (conf.node.hinted_scheduler.hinting_threshold_percent, defaults.node.hinted_scheduler.hinting_threshold_percent); ASSERT_NE (conf.node.hinted_scheduler.check_interval.count (), defaults.node.hinted_scheduler.check_interval.count ()); ASSERT_NE (conf.node.hinted_scheduler.block_cooldown.count (), defaults.node.hinted_scheduler.block_cooldown.count ()); + ASSERT_NE (conf.node.hinted_scheduler.vacancy_threshold_percent, defaults.node.hinted_scheduler.vacancy_threshold_percent); ASSERT_NE (conf.node.vote_cache.max_size, defaults.node.vote_cache.max_size); ASSERT_NE (conf.node.vote_cache.max_voters, defaults.node.vote_cache.max_voters); diff --git a/nano/node/scheduler/hinted.cpp b/nano/node/scheduler/hinted.cpp index eb8bca05d9..6bbaff7de9 100644 --- a/nano/node/scheduler/hinted.cpp +++ b/nano/node/scheduler/hinted.cpp @@ -47,7 +47,7 @@ void nano::scheduler::hinted::notify () { // Avoid notifying when there is very little space inside AEC auto const limit = active.limit (nano::election_behavior::hinted); - if (active.vacancy (nano::election_behavior::hinted) >= (limit * config.vaccancy_threshold_percent / 100)) + if (active.vacancy (nano::election_behavior::hinted) >= (limit * config.vacancy_threshold_percent / 100)) { condition.notify_all (); } @@ -230,6 +230,7 @@ nano::error nano::scheduler::hinted_config::serialize (nano::tomlconfig & toml) toml.put ("hinting_threshold", hinting_threshold_percent, "Percentage of online weight needed to start a hinted election. \ntype:uint32,[0,100]"); toml.put ("check_interval", check_interval.count (), "Interval between scans of the vote cache for possible hinted elections. \ntype:milliseconds"); toml.put ("block_cooldown", block_cooldown.count (), "Cooldown period for blocks that failed to start an election. \ntype:milliseconds"); + toml.put ("vacancy_threshold", vacancy_threshold_percent, "Percentage of available space in the active elections container needed to trigger a scan for hinted elections (before the check interval elapses). \ntype:uint32,[0,100]"); return toml.get_error (); } @@ -246,10 +247,16 @@ nano::error nano::scheduler::hinted_config::deserialize (nano::tomlconfig & toml toml.get ("block_cooldown", block_cooldown_l); block_cooldown = std::chrono::milliseconds{ block_cooldown_l }; + toml.get ("vacancy_threshold", vacancy_threshold_percent); + if (hinting_threshold_percent > 100) { toml.get_error ().set ("hinting_threshold must be a number between 0 and 100"); } + if (vacancy_threshold_percent > 100) + { + toml.get_error ().set ("vacancy_threshold must be a number between 0 and 100"); + } return toml.get_error (); } \ No newline at end of file diff --git a/nano/node/scheduler/hinted.hpp b/nano/node/scheduler/hinted.hpp index b73858f554..a80bb68c05 100644 --- a/nano/node/scheduler/hinted.hpp +++ b/nano/node/scheduler/hinted.hpp @@ -39,7 +39,7 @@ class hinted_config final std::chrono::milliseconds check_interval{ 1000 }; std::chrono::milliseconds block_cooldown{ 10000 }; unsigned hinting_threshold_percent{ 10 }; - unsigned vaccancy_threshold_percent{ 20 }; + unsigned vacancy_threshold_percent{ 20 }; }; /* diff --git a/nano/node/vote_cache.cpp b/nano/node/vote_cache.cpp index 0125515897..b6e2bb8040 100644 --- a/nano/node/vote_cache.cpp +++ b/nano/node/vote_cache.cpp @@ -268,6 +268,7 @@ nano::error nano::vote_cache_config::serialize (nano::tomlconfig & toml) const { toml.put ("max_size", max_size, "Maximum number of blocks to cache votes for. \ntype:uint64"); toml.put ("max_voters", max_voters, "Maximum number of voters to cache per block. \ntype:uint64"); + toml.put ("age_cutoff", age_cutoff.count (), "Maximum age of votes to keep in cache. \ntype:seconds"); return toml.get_error (); } @@ -277,5 +278,9 @@ nano::error nano::vote_cache_config::deserialize (nano::tomlconfig & toml) toml.get ("max_size", max_size); toml.get ("max_voters", max_voters); + auto age_cutoff_l = age_cutoff.count (); + toml.get ("age_cutoff", age_cutoff_l); + age_cutoff = std::chrono::seconds{ age_cutoff_l }; + return toml.get_error (); } \ No newline at end of file