Move from constexpr to bootstrap ascending account_sets_config class
This commit is contained in:
parent
7f9a518b02
commit
926931b7db
2 changed files with 11 additions and 12 deletions
|
|
@ -119,8 +119,9 @@ void nano::bootstrap_ascending::buffered_iterator::fill ()
|
|||
* account_sets
|
||||
*/
|
||||
|
||||
nano::bootstrap_ascending::account_sets::account_sets (nano::stats & stats_a) :
|
||||
stats{ stats_a }
|
||||
nano::bootstrap_ascending::account_sets::account_sets (nano::stats & stats_a, nano::account_sets_config config_a) :
|
||||
stats{ stats_a },
|
||||
config{ std::move (config_a) }
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -239,7 +240,7 @@ bool nano::bootstrap_ascending::account_sets::check_timestamp (const nano::accou
|
|||
auto iter = priorities.get<tag_account> ().find (account);
|
||||
if (iter != priorities.get<tag_account> ().end ())
|
||||
{
|
||||
if (nano::milliseconds_since_epoch () - iter->timestamp < cooldown)
|
||||
if (nano::milliseconds_since_epoch () - iter->timestamp < config.cooldown)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
@ -249,14 +250,14 @@ bool nano::bootstrap_ascending::account_sets::check_timestamp (const nano::accou
|
|||
|
||||
void nano::bootstrap_ascending::account_sets::trim_overflow ()
|
||||
{
|
||||
if (priorities.size () > priorities_max)
|
||||
if (priorities.size () > config.priorities_max)
|
||||
{
|
||||
// Evict the lowest priority entry
|
||||
priorities.get<tag_priority> ().erase (priorities.get<tag_priority> ().begin ());
|
||||
|
||||
stats.inc (nano::stat::type::bootstrap_ascending_accounts, nano::stat::detail::priority_erase_overflow);
|
||||
}
|
||||
if (blocking.size () > blocking_max)
|
||||
if (blocking.size () > config.blocking_max)
|
||||
{
|
||||
// Evict the lowest priority entry
|
||||
blocking.get<tag_priority> ().erase (blocking.get<tag_priority> ().begin ());
|
||||
|
|
@ -276,7 +277,7 @@ nano::account nano::bootstrap_ascending::account_sets::next ()
|
|||
std::vector<nano::account> candidates;
|
||||
|
||||
int iterations = 0;
|
||||
while (candidates.size () < account_sets::consideration_count && iterations++ < account_sets::consideration_count * 10)
|
||||
while (candidates.size () < config.consideration_count && iterations++ < config.consideration_count * 10)
|
||||
{
|
||||
debug_assert (candidates.size () == weights.size ());
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
#include <nano/lib/timer.hpp>
|
||||
#include <nano/node/bandwidth_limiter.hpp>
|
||||
#include <nano/node/bootstrap/bootstrap_attempt.hpp>
|
||||
#include <nano/node/bootstrap/bootstrap_config.hpp>
|
||||
#include <nano/node/bootstrap/bootstrap_server.hpp>
|
||||
|
||||
#include <boost/multi_index/hashed_index.hpp>
|
||||
|
|
@ -131,7 +132,7 @@ public: // account_sets
|
|||
class account_sets
|
||||
{
|
||||
public:
|
||||
explicit account_sets (nano::stats &);
|
||||
explicit account_sets (nano::stats &, nano::account_sets_config config = {});
|
||||
|
||||
/**
|
||||
* If an account is not blocked, increase its priority.
|
||||
|
|
@ -229,11 +230,8 @@ public: // account_sets
|
|||
|
||||
std::default_random_engine rng;
|
||||
|
||||
private: // TODO: Move into config
|
||||
static std::size_t constexpr consideration_count = 4;
|
||||
static std::size_t constexpr priorities_max = 256 * 1024;
|
||||
static std::size_t constexpr blocking_max = 256 * 1024;
|
||||
static nano::millis_t constexpr cooldown = 3 * 1000;
|
||||
private:
|
||||
nano::account_sets_config config;
|
||||
|
||||
public: // Consts
|
||||
static float constexpr priority_initial = 8.0f;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue