diff --git a/nano/node/scheduler/optimistic.cpp b/nano/node/scheduler/optimistic.cpp index caab43c70e..13f1e331b6 100644 --- a/nano/node/scheduler/optimistic.cpp +++ b/nano/node/scheduler/optimistic.cpp @@ -9,14 +9,27 @@ #include #include -nano::scheduler::optimistic::optimistic (optimistic_config const & config_a, nano::node & node_a, nano::ledger & ledger_a, nano::active_elections & active_a, nano::network_constants const & network_constants_a, nano::stats & stats_a) : +nano::scheduler::optimistic::optimistic (optimistic_config const & config_a, nano::node & node_a, nano::node_observers & observers_a, nano::ledger & ledger_a, nano::active_elections & active_a, nano::network_constants const & network_constants_a, nano::stats & stats_a) : config{ config_a }, node{ node_a }, + observers{ observers_a }, ledger{ ledger_a }, active{ active_a }, network_constants{ network_constants_a }, stats{ stats_a } { + observers.account_bootstrapped.add ([this] (nano::account const & account) { + auto transaction = ledger.tx_begin_read (); + if (auto account_info = ledger.any.account_get (transaction, account)) + { + nano::confirmation_height_info conf_info; + ledger.store.confirmation_height.get (transaction, account, conf_info); + if (activate_predicate (*account_info, conf_info)) + { + activate (account, *account_info, conf_info); + } + } + }); } nano::scheduler::optimistic::~optimistic () diff --git a/nano/node/scheduler/optimistic.hpp b/nano/node/scheduler/optimistic.hpp index 24edd1e73e..6752f65be4 100644 --- a/nano/node/scheduler/optimistic.hpp +++ b/nano/node/scheduler/optimistic.hpp @@ -44,15 +44,12 @@ class optimistic final struct entry; public: - optimistic (optimistic_config const &, nano::node &, nano::ledger &, nano::active_elections &, nano::network_constants const & network_constants, nano::stats &); + optimistic (optimistic_config const &, nano::node &, nano::node_observers &, nano::ledger &, nano::active_elections &, nano::network_constants const &, nano::stats &); ~optimistic (); void start (); void stop (); - /** - * Called from backlog population to process accounts with unconfirmed blocks - */ bool activate (nano::account const &, nano::account_info const &, nano::confirmation_height_info const &); /** @@ -72,6 +69,7 @@ class optimistic final private: // Dependencies optimistic_config const & config; nano::node & node; + nano::node_observers & observers; nano::ledger & ledger; nano::active_elections & active; nano::network_constants const & network_constants; @@ -97,7 +95,8 @@ class optimistic final // clang-format on /** Accounts eligible for optimistic scheduling */ - ordered_candidates candidates; + ordered_candidates random_candidates; + ordered_candidates priority_candidates; bool stopped{ false }; nano::condition_variable condition;