Activate accounts with freshly processed blocks

This commit is contained in:
Piotr Wójcik 2024-10-17 17:13:58 +02:00
commit d22b69c934
6 changed files with 22 additions and 14 deletions

View file

@ -137,7 +137,7 @@ nano::node::node (std::shared_ptr<boost::asio::io_context> io_ctx_a, std::filesy
generator{ *generator_impl },
final_generator_impl{ std::make_unique<nano::vote_generator> (config, *this, ledger, wallets, vote_processor, history, network, stats, logger, /* final */ true) },
final_generator{ *final_generator_impl },
scheduler_impl{ std::make_unique<nano::scheduler::component> (config, *this, ledger, active, online_reps, vote_cache, stats, logger) },
scheduler_impl{ std::make_unique<nano::scheduler::component> (config, *this, ledger, block_processor, active, online_reps, vote_cache, stats, logger) },
scheduler{ *scheduler_impl },
aggregator_impl{ std::make_unique<nano::request_aggregator> (config.request_aggregator, *this, stats, generator, final_generator, history, ledger, wallets, vote_router) },
aggregator{ *aggregator_impl },

View file

@ -43,12 +43,6 @@ void nano::process_live_dispatcher::inspect (nano::block_status const & result,
void nano::process_live_dispatcher::process_live (nano::block const & block, secure::transaction const & transaction)
{
// Start collecting quorum on block
if (ledger.dependents_confirmed (transaction, block))
{
scheduler.activate (transaction, block.account ());
}
if (websocket.server && websocket.server->any_subscriber (nano::websocket::topic::new_unconfirmed_block))
{
websocket.server->broadcast (nano::websocket::message_builder ().new_block_arrived (block));

View file

@ -5,11 +5,11 @@
#include <nano/node/scheduler/optimistic.hpp>
#include <nano/node/scheduler/priority.hpp>
nano::scheduler::component::component (nano::node_config & node_config, nano::node & node, nano::ledger & ledger, nano::active_elections & active, nano::online_reps & online_reps, nano::vote_cache & vote_cache, nano::stats & stats, nano::logger & logger) :
nano::scheduler::component::component (nano::node_config & node_config, nano::node & node, nano::ledger & ledger, nano::block_processor & block_processor, nano::active_elections & active, nano::online_reps & online_reps, nano::vote_cache & vote_cache, nano::stats & stats, nano::logger & logger) :
hinted_impl{ std::make_unique<nano::scheduler::hinted> (node_config.hinted_scheduler, node, vote_cache, active, online_reps, stats) },
manual_impl{ std::make_unique<nano::scheduler::manual> (node) },
optimistic_impl{ std::make_unique<nano::scheduler::optimistic> (node_config.optimistic_scheduler, node, ledger, active, node_config.network_params.network, stats) },
priority_impl{ std::make_unique<nano::scheduler::priority> (node_config, node, ledger, active, stats, logger) },
priority_impl{ std::make_unique<nano::scheduler::priority> (node_config, node, ledger, block_processor, active, stats, logger) },
hinted{ *hinted_impl },
manual{ *manual_impl },
optimistic{ *optimistic_impl },

View file

@ -10,7 +10,7 @@ namespace nano::scheduler
class component final
{
public:
component (nano::node_config &, nano::node &, nano::ledger &, nano::active_elections &, nano::online_reps &, nano::vote_cache &, nano::stats &, nano::logger &);
component (nano::node_config &, nano::node &, nano::ledger &, nano::block_processor &, nano::active_elections &, nano::online_reps &, nano::vote_cache &, nano::stats &, nano::logger &);
~component ();
void start ();

View file

@ -7,10 +7,11 @@
#include <nano/secure/ledger_set_any.hpp>
#include <nano/secure/ledger_set_confirmed.hpp>
nano::scheduler::priority::priority (nano::node_config & node_config, nano::node & node_a, nano::ledger & ledger_a, nano::active_elections & active_a, nano::stats & stats_a, nano::logger & logger_a) :
nano::scheduler::priority::priority (nano::node_config & node_config, nano::node & node_a, nano::ledger & ledger_a, nano::block_processor & block_processor_a, nano::active_elections & active_a, nano::stats & stats_a, nano::logger & logger_a) :
config{ node_config.priority_scheduler },
node{ node_a },
ledger{ ledger_a },
block_processor{ block_processor_a },
active{ active_a },
stats{ stats_a },
logger{ logger_a }
@ -44,6 +45,19 @@ nano::scheduler::priority::priority (nano::node_config & node_config, nano::node
auto bucket = std::make_unique<scheduler::bucket> (minimums[i], node_config.priority_bucket, active, stats);
buckets.emplace_back (std::move (bucket));
}
// Activate accounts with fresh blocks
block_processor.batch_processed.add ([this] (auto const & batch) {
auto transaction = ledger.tx_begin_read ();
for (auto const & [result, context] : batch)
{
if (result == nano::block_status::progress)
{
release_assert (context.block != nullptr);
activate (transaction, context.block->account ());
}
}
});
}
nano::scheduler::priority::~priority ()
@ -88,8 +102,7 @@ void nano::scheduler::priority::stop ()
bool nano::scheduler::priority::activate (secure::transaction const & transaction, nano::account const & account)
{
debug_assert (!account.is_zero ());
auto info = ledger.any.account_get (transaction, account);
if (info)
if (auto info = ledger.any.account_get (transaction, account))
{
nano::confirmation_height_info conf_info;
ledger.store.confirmation_height.get (transaction, account, conf_info);

View file

@ -26,7 +26,7 @@ public:
class priority final
{
public:
priority (nano::node_config &, nano::node &, nano::ledger &, nano::active_elections &, nano::stats &, nano::logger &);
priority (nano::node_config &, nano::node &, nano::ledger &, nano::block_processor &, nano::active_elections &, nano::stats &, nano::logger &);
~priority ();
void start ();
@ -49,6 +49,7 @@ private: // Dependencies
priority_config const & config;
nano::node & node;
nano::ledger & ledger;
nano::block_processor & block_processor;
nano::active_elections & active;
nano::stats & stats;
nano::logger & logger;