diff --git a/nano/node/CMakeLists.txt b/nano/node/CMakeLists.txt index f50649b047..27b95f0d22 100644 --- a/nano/node/CMakeLists.txt +++ b/nano/node/CMakeLists.txt @@ -16,8 +16,8 @@ add_library( ${platform_sources} active_elections.hpp active_elections.cpp - backlog_population.hpp - backlog_population.cpp + backlog_scan.hpp + backlog_scan.cpp bandwidth_limiter.hpp bandwidth_limiter.cpp blockprocessor.hpp diff --git a/nano/node/backlog_population.cpp b/nano/node/backlog_scan.cpp similarity index 81% rename from nano/node/backlog_population.cpp rename to nano/node/backlog_scan.cpp index 284b7c599e..9d59a24e69 100644 --- a/nano/node/backlog_population.cpp +++ b/nano/node/backlog_scan.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include #include #include #include @@ -8,7 +8,7 @@ #include #include -nano::backlog_population::backlog_population (backlog_population_config const & config_a, nano::scheduler::component & schedulers, nano::ledger & ledger, nano::stats & stats_a) : +nano::backlog_scan::backlog_scan (backlog_scan_config const & config_a, nano::scheduler::component & schedulers, nano::ledger & ledger, nano::stats & stats_a) : config{ config_a }, schedulers{ schedulers }, ledger{ ledger }, @@ -16,13 +16,13 @@ nano::backlog_population::backlog_population (backlog_population_config const & { } -nano::backlog_population::~backlog_population () +nano::backlog_scan::~backlog_scan () { // Thread must be stopped before destruction debug_assert (!thread.joinable ()); } -void nano::backlog_population::start () +void nano::backlog_scan::start () { debug_assert (!thread.joinable ()); @@ -32,7 +32,7 @@ void nano::backlog_population::start () } }; } -void nano::backlog_population::stop () +void nano::backlog_scan::stop () { { nano::lock_guard lock{ mutex }; @@ -42,7 +42,7 @@ void nano::backlog_population::stop () nano::join_or_pass (thread); } -void nano::backlog_population::trigger () +void nano::backlog_scan::trigger () { { nano::unique_lock lock{ mutex }; @@ -51,17 +51,17 @@ void nano::backlog_population::trigger () notify (); } -void nano::backlog_population::notify () +void nano::backlog_scan::notify () { condition.notify_all (); } -bool nano::backlog_population::predicate () const +bool nano::backlog_scan::predicate () const { return triggered || config.enable; } -void nano::backlog_population::run () +void nano::backlog_scan::run () { nano::unique_lock lock{ mutex }; while (!stopped) @@ -80,7 +80,7 @@ void nano::backlog_population::run () } } -void nano::backlog_population::populate_backlog (nano::unique_lock & lock) +void nano::backlog_scan::populate_backlog (nano::unique_lock & lock) { debug_assert (config.frequency > 0); @@ -125,7 +125,7 @@ void nano::backlog_population::populate_backlog (nano::unique_lock } } -void nano::backlog_population::activate (secure::transaction const & transaction, nano::account const & account, nano::account_info const & account_info) +void nano::backlog_scan::activate (secure::transaction const & transaction, nano::account const & account, nano::account_info const & account_info) { auto const maybe_conf_info = ledger.store.confirmation_height.get (transaction, account); auto const conf_info = maybe_conf_info.value_or (nano::confirmation_height_info{}); @@ -146,7 +146,7 @@ void nano::backlog_population::activate (secure::transaction const & transaction * backlog_population_config */ -nano::error nano::backlog_population_config::serialize (nano::tomlconfig & toml) const +nano::error nano::backlog_scan_config::serialize (nano::tomlconfig & toml) const { toml.put ("enable", enable, "Control if ongoing backlog population is enabled. If not, backlog population can still be triggered by RPC \ntype:bool"); toml.put ("batch_size", batch_size, "Number of accounts per second to process when doing backlog population scan. Increasing this value will help unconfirmed frontiers get into election prioritization queue faster, however it will also increase resource usage. \ntype:uint"); @@ -155,7 +155,7 @@ nano::error nano::backlog_population_config::serialize (nano::tomlconfig & toml) return toml.get_error (); } -nano::error nano::backlog_population_config::deserialize (nano::tomlconfig & toml) +nano::error nano::backlog_scan_config::deserialize (nano::tomlconfig & toml) { toml.get ("enable", enable); toml.get ("batch_size", batch_size); diff --git a/nano/node/backlog_population.hpp b/nano/node/backlog_scan.hpp similarity index 84% rename from nano/node/backlog_population.hpp rename to nano/node/backlog_scan.hpp index 37123f4ba9..f9b2ba8aad 100644 --- a/nano/node/backlog_population.hpp +++ b/nano/node/backlog_scan.hpp @@ -3,24 +3,16 @@ #include #include #include +#include #include #include #include #include -namespace nano::secure -{ -class transaction; -} namespace nano { -class account_info; -class election_scheduler; -class ledger; -class stats; - -class backlog_population_config final +class backlog_scan_config final { public: nano::error deserialize (nano::tomlconfig &); @@ -35,11 +27,11 @@ class backlog_population_config final unsigned frequency{ 10 }; }; -class backlog_population final +class backlog_scan final { public: - backlog_population (backlog_population_config const &, nano::scheduler::component &, nano::ledger &, nano::stats &); - ~backlog_population (); + backlog_scan (backlog_scan_config const &, nano::scheduler::component &, nano::ledger &, nano::stats &); + ~backlog_scan (); void start (); void stop (); @@ -58,7 +50,7 @@ class backlog_population final callback_t activate_callback; private: // Dependencies - backlog_population_config const & config; + backlog_scan_config const & config; nano::scheduler::component & schedulers; nano::ledger & ledger; nano::stats & stats; diff --git a/nano/node/node.cpp b/nano/node/node.cpp index 350b94a0e9..45e73b1692 100644 --- a/nano/node/node.cpp +++ b/nano/node/node.cpp @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include #include #include @@ -154,7 +154,7 @@ nano::node::node (std::shared_ptr io_ctx_a, std::filesy aggregator_impl{ std::make_unique (config.request_aggregator, *this, stats, generator, final_generator, history, ledger, wallets, vote_router) }, aggregator{ *aggregator_impl }, wallets (wallets_store.init_error (), *this), - backlog_scan_impl{ std::make_unique (config.backlog_population, scheduler, ledger, stats) }, + backlog_scan_impl{ std::make_unique (config.backlog_population, scheduler, ledger, stats) }, backlog_scan{ *backlog_scan_impl }, bootstrap_server_impl{ std::make_unique (config.bootstrap_server, store, ledger, network_params.network, stats) }, bootstrap_server{ *bootstrap_server_impl }, diff --git a/nano/node/node.hpp b/nano/node/node.hpp index 1912e70992..a471942378 100644 --- a/nano/node/node.hpp +++ b/nano/node/node.hpp @@ -33,7 +33,7 @@ namespace nano { class active_elections; -class backlog_population; +class backlog_scan; class bandwidth_limiter; class confirming_set; class message_processor; @@ -205,8 +205,8 @@ class node final : public std::enable_shared_from_this std::unique_ptr aggregator_impl; nano::request_aggregator & aggregator; nano::wallets wallets; - std::unique_ptr backlog_scan_impl; - nano::backlog_population & backlog_scan; + std::unique_ptr backlog_scan_impl; + nano::backlog_scan & backlog_scan; std::unique_ptr bootstrap_server_impl; nano::bootstrap_server & bootstrap_server; std::unique_ptr bootstrap_impl; diff --git a/nano/node/nodeconfig.hpp b/nano/node/nodeconfig.hpp index aa5a13f8f4..15498843f8 100644 --- a/nano/node/nodeconfig.hpp +++ b/nano/node/nodeconfig.hpp @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include #include @@ -146,7 +146,7 @@ class node_config nano::local_block_broadcaster_config local_block_broadcaster; nano::confirming_set_config confirming_set; nano::monitor_config monitor; - nano::backlog_population_config backlog_population; + nano::backlog_scan_config backlog_population; public: /** Entry is ignored if it cannot be parsed as a valid address:port */