diff --git a/nano/node/bootstrap/bootstrap_service.cpp b/nano/node/bootstrap/bootstrap_service.cpp index ebee542953..a587717364 100644 --- a/nano/node/bootstrap/bootstrap_service.cpp +++ b/nano/node/bootstrap/bootstrap_service.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -18,9 +19,10 @@ using namespace std::chrono_literals; -nano::bootstrap_service::bootstrap_service (nano::node_config const & node_config_a, nano::block_processor & block_processor_a, nano::ledger & ledger_a, nano::network & network_a, nano::stats & stat_a, nano::logger & logger_a) : +nano::bootstrap_service::bootstrap_service (nano::node_config const & node_config_a, nano::node_observers & observers_a, nano::block_processor & block_processor_a, nano::ledger & ledger_a, nano::network & network_a, nano::stats & stat_a, nano::logger & logger_a) : config{ node_config_a.bootstrap }, network_constants{ node_config_a.network_params.network }, + observers{ observers_a }, block_processor{ block_processor_a }, ledger{ ledger_a }, network{ network_a }, @@ -299,7 +301,7 @@ void nano::bootstrap_service::inspect (secure::transaction const & tx, nano::blo bool blocked = accounts.block (account, source_hash); if (blocked) { - account_done.notify (account); + observers.account_bootstrapped.notify (account); } } } @@ -865,7 +867,7 @@ bool nano::bootstrap_service::process (const nano::asc_pull_ack::blocks_payload bool erased = accounts.priority_down (tag.account); if (erased) { - account_done.notify (tag.account); + observers.account_bootstrapped.notify (tag.account); } accounts.timestamp_reset (tag.account); diff --git a/nano/node/bootstrap/bootstrap_service.hpp b/nano/node/bootstrap/bootstrap_service.hpp index adf54abc1c..357bc15772 100644 --- a/nano/node/bootstrap/bootstrap_service.hpp +++ b/nano/node/bootstrap/bootstrap_service.hpp @@ -30,15 +30,13 @@ namespace nano class bootstrap_service { public: - bootstrap_service (nano::node_config const &, nano::block_processor &, nano::ledger &, nano::network &, nano::stats &, nano::logger &); + bootstrap_service (nano::node_config const &, nano::node_observers &, nano::block_processor &, nano::ledger &, nano::network &, nano::stats &, nano::logger &); ~bootstrap_service (); void start (); void stop (); - /** - * Process `asc_pull_ack` message coming from network - */ + /** Process messages coming from network */ void process (nano::asc_pull_ack const & message, std::shared_ptr const &); std::size_t blocked_size () const; @@ -52,12 +50,10 @@ class bootstrap_service nano::bootstrap::account_sets::info_t info () const; -public: // Events - nano::observer_set account_done; - private: // Dependencies bootstrap_config const & config; nano::network_constants const & network_constants; + nano::node_observers & observers; nano::block_processor & block_processor; nano::ledger & ledger; nano::network & network; diff --git a/nano/node/fwd.hpp b/nano/node/fwd.hpp index e477f8414a..702a51f2e8 100644 --- a/nano/node/fwd.hpp +++ b/nano/node/fwd.hpp @@ -18,6 +18,7 @@ class bootstrap_server; class bootstrap_service; class confirming_set; class election; +class election_status; class local_block_broadcaster; class local_vote_history; class logger; diff --git a/nano/node/node.cpp b/nano/node/node.cpp index 5e87808671..de31e9ae06 100644 --- a/nano/node/node.cpp +++ b/nano/node/node.cpp @@ -164,7 +164,7 @@ nano::node::node (std::shared_ptr io_ctx_a, std::filesy backlog{ *backlog_impl }, bootstrap_server_impl{ std::make_unique (config.bootstrap_server, store, ledger, network_params.network, stats) }, bootstrap_server{ *bootstrap_server_impl }, - bootstrap_impl{ std::make_unique (config, block_processor, ledger, network, stats, logger) }, + bootstrap_impl{ std::make_unique (config, observers, block_processor, ledger, network, stats, logger) }, bootstrap{ *bootstrap_impl }, websocket{ config.websocket_config, observers, wallets, ledger, io_ctx, logger }, epoch_upgrader{ *this, ledger, store, network_params, logger }, diff --git a/nano/node/node_observers.hpp b/nano/node/node_observers.hpp index 1c6d36ed40..3ce6c17442 100644 --- a/nano/node/node_observers.hpp +++ b/nano/node/node_observers.hpp @@ -2,28 +2,17 @@ #include #include +#include #include #include -namespace nano -{ -enum class vote_source; -class election_status; -class telemetry; -enum class vote_code; -} -namespace nano::transport -{ -class channel; -} - namespace nano { class node_observers final { public: - using blocks_t = nano::observer_set const &, nano::account const &, nano::uint128_t const &, bool, bool>; - blocks_t blocks; // Notification upon election completion or cancellation + using blocks_event = nano::observer_set const &, nano::account const &, nano::uint128_t const &, bool, bool>; + blocks_event blocks; // Notification upon election completion or cancellation nano::observer_set wallet; nano::observer_set, std::shared_ptr, nano::vote_source, nano::vote_code> vote; nano::observer_set active_started; @@ -35,6 +24,10 @@ class node_observers final nano::observer_set const &> telemetry; nano::observer_set socket_connected; + // Called when an account that was being bootstrapped is now likely up-to-date + nano::observer_set account_bootstrapped; + +public: nano::container_info container_info () const; }; }