Skip to content

Commit

Permalink
Rename class to backlog_scan
Browse files Browse the repository at this point in the history
  • Loading branch information
pwojcikdev committed Nov 25, 2024
1 parent 6a371fd commit 681d5f8
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 36 deletions.
4 changes: 2 additions & 2 deletions nano/node/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 13 additions & 13 deletions nano/node/backlog_population.cpp → nano/node/backlog_scan.cpp
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
#include <nano/lib/thread_roles.hpp>
#include <nano/lib/threading.hpp>
#include <nano/node/backlog_population.hpp>
#include <nano/node/backlog_scan.hpp>
#include <nano/node/nodeconfig.hpp>
#include <nano/node/scheduler/priority.hpp>
#include <nano/secure/ledger.hpp>
#include <nano/store/account.hpp>
#include <nano/store/component.hpp>
#include <nano/store/confirmation_height.hpp>

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 },
stats{ stats_a }
{
}

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 ());

Expand All @@ -32,7 +32,7 @@ void nano::backlog_population::start ()
} };
}

void nano::backlog_population::stop ()
void nano::backlog_scan::stop ()
{
{
nano::lock_guard<nano::mutex> lock{ mutex };
Expand All @@ -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<nano::mutex> lock{ mutex };
Expand All @@ -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<nano::mutex> lock{ mutex };
while (!stopped)
Expand All @@ -80,7 +80,7 @@ void nano::backlog_population::run ()
}
}

void nano::backlog_population::populate_backlog (nano::unique_lock<nano::mutex> & lock)
void nano::backlog_scan::populate_backlog (nano::unique_lock<nano::mutex> & lock)
{
debug_assert (config.frequency > 0);

Expand Down Expand Up @@ -125,7 +125,7 @@ void nano::backlog_population::populate_backlog (nano::unique_lock<nano::mutex>
}
}

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{});
Expand All @@ -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");
Expand All @@ -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);
Expand Down
20 changes: 6 additions & 14 deletions nano/node/backlog_population.hpp → nano/node/backlog_scan.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,16 @@
#include <nano/lib/locks.hpp>
#include <nano/lib/numbers.hpp>
#include <nano/lib/observer_set.hpp>
#include <nano/node/fwd.hpp>
#include <nano/node/scheduler/component.hpp>
#include <nano/secure/common.hpp>

#include <condition_variable>
#include <thread>

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 &);
Expand All @@ -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 ();
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions nano/node/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <nano/lib/utility.hpp>
#include <nano/lib/work_version.hpp>
#include <nano/node/active_elections.hpp>
#include <nano/node/backlog_population.hpp>
#include <nano/node/backlog_scan.hpp>
#include <nano/node/bandwidth_limiter.hpp>
#include <nano/node/bootstrap/bootstrap_server.hpp>
#include <nano/node/bootstrap/bootstrap_service.hpp>
Expand Down Expand Up @@ -154,7 +154,7 @@ nano::node::node (std::shared_ptr<boost::asio::io_context> io_ctx_a, std::filesy
aggregator_impl{ std::make_unique<nano::request_aggregator> (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<nano::backlog_population> (config.backlog_population, scheduler, ledger, stats) },
backlog_scan_impl{ std::make_unique<nano::backlog_scan> (config.backlog_population, scheduler, ledger, stats) },
backlog_scan{ *backlog_scan_impl },
bootstrap_server_impl{ std::make_unique<nano::bootstrap_server> (config.bootstrap_server, store, ledger, network_params.network, stats) },
bootstrap_server{ *bootstrap_server_impl },
Expand Down
6 changes: 3 additions & 3 deletions nano/node/node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
namespace nano
{
class active_elections;
class backlog_population;
class backlog_scan;
class bandwidth_limiter;
class confirming_set;
class message_processor;
Expand Down Expand Up @@ -205,8 +205,8 @@ class node final : public std::enable_shared_from_this<node>
std::unique_ptr<nano::request_aggregator> aggregator_impl;
nano::request_aggregator & aggregator;
nano::wallets wallets;
std::unique_ptr<nano::backlog_population> backlog_scan_impl;
nano::backlog_population & backlog_scan;
std::unique_ptr<nano::backlog_scan> backlog_scan_impl;
nano::backlog_scan & backlog_scan;
std::unique_ptr<nano::bootstrap_server> bootstrap_server_impl;
nano::bootstrap_server & bootstrap_server;
std::unique_ptr<nano::bootstrap_service> bootstrap_impl;
Expand Down
4 changes: 2 additions & 2 deletions nano/node/nodeconfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <nano/lib/rocksdbconfig.hpp>
#include <nano/lib/stats.hpp>
#include <nano/node/active_elections.hpp>
#include <nano/node/backlog_population.hpp>
#include <nano/node/backlog_scan.hpp>
#include <nano/node/blockprocessor.hpp>
#include <nano/node/bootstrap/bootstrap_config.hpp>
#include <nano/node/bootstrap/bootstrap_server.hpp>
Expand Down Expand Up @@ -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 */
Expand Down

0 comments on commit 681d5f8

Please sign in to comment.