diff --git a/include/bitcoin/node/full_node.hpp b/include/bitcoin/node/full_node.hpp index 25f81579..71068757 100644 --- a/include/bitcoin/node/full_node.hpp +++ b/include/bitcoin/node/full_node.hpp @@ -151,6 +151,9 @@ class BCN_API full_node /// Methods. /// ----------------------------------------------------------------------- + /// Expose the host pool fetch for administrative queries. + void fetch(network::address_handler&& handler) NOEXCEPT override; + /// Get current fee estimate. void estimate(size_t target, estimator::mode mode, estimate_handler&& handler) NOEXCEPT; diff --git a/include/bitcoin/node/protocols/protocol.hpp b/include/bitcoin/node/protocols/protocol.hpp index 3a7d4cc9..946310b6 100644 --- a/include/bitcoin/node/protocols/protocol.hpp +++ b/include/bitcoin/node/protocols/protocol.hpp @@ -77,13 +77,42 @@ class BCN_API protocol /// The number of inbound peer channels (counted, not quiet). virtual size_t inbound_channel_count() const NOEXCEPT; + /// The number of host pool addresses. + virtual size_t address_count() const NOEXCEPT; + /// Methods. /// ----------------------------------------------------------------------- + /// Fetch a copy of the host pool addresses. + virtual void fetch_addresses( + network::address_handler&& handler) const NOEXCEPT; + + /// Maintain a manual connection to the given endpoint. + virtual void connect(const network::config::endpoint& endpoint) NOEXCEPT; + /// Get current fee estimate. void estimate(size_t target, estimator::mode mode, estimate_handler&& handler) NOEXCEPT; + /// Suspensions. + /// ----------------------------------------------------------------------- + + /// Network suspension (does not affect administrative connections). + virtual bool suspended() const NOEXCEPT; + virtual void suspend(const code& ec) NOEXCEPT; + virtual void resume() NOEXCEPT; + + /// Organizers. + /// ----------------------------------------------------------------------- + + /// Organize a validated header. + virtual void organize(const system::chain::header::cptr& header, + organize_handler&& handler) NOEXCEPT; + + /// Organize a checked block. + virtual void organize(const system::chain::block::cptr& block, + organize_handler&& handler) NOEXCEPT; + /// Events subscription. /// ----------------------------------------------------------------------- diff --git a/include/bitcoin/node/protocols/protocol_peer.hpp b/include/bitcoin/node/protocols/protocol_peer.hpp index e5973a56..f083b326 100644 --- a/include/bitcoin/node/protocols/protocol_peer.hpp +++ b/include/bitcoin/node/protocols/protocol_peer.hpp @@ -56,14 +56,6 @@ class BCN_API protocol_peer /// Organizers. /// ----------------------------------------------------------------------- - /// Organize a validated header. - virtual void organize(const system::chain::header::cptr& header, - organize_handler&& handler) NOEXCEPT; - - /// Organize a checked block. - virtual void organize(const system::chain::block::cptr& block, - organize_handler&& handler) NOEXCEPT; - /// Get block hashes for blocks to download. virtual void get_hashes(map_handler&& handler) NOEXCEPT; diff --git a/include/bitcoin/node/sessions/session.hpp b/include/bitcoin/node/sessions/session.hpp index 8b0772f6..51b438f4 100644 --- a/include/bitcoin/node/sessions/session.hpp +++ b/include/bitcoin/node/sessions/session.hpp @@ -76,6 +76,13 @@ class BCN_API session /// Methods. /// ----------------------------------------------------------------------- + /// Fetch a copy of the host pool addresses. + virtual void fetch_addresses( + network::address_handler&& handler) const NOEXCEPT; + + /// Maintain a manual connection to the given endpoint. + virtual void connect(const network::config::endpoint& endpoint) NOEXCEPT; + /// Get current fee estimate. void estimate(size_t target, estimator::mode mode, estimate_handler&& handler) NOEXCEPT; @@ -87,6 +94,11 @@ class BCN_API session /// Suspensions. /// ----------------------------------------------------------------------- + /// Network suspension (does not affect administrative connections). + virtual bool suspended() const NOEXCEPT; + virtual void suspend(const code& ec) NOEXCEPT; + virtual void resume() NOEXCEPT; + /// Suspend all connections. virtual void fault(const code& ec) NOEXCEPT; @@ -118,6 +130,10 @@ class BCN_API session /// The number of inbound peer channels (counted, not quiet). virtual size_t inbound_channel_count() const NOEXCEPT; + /// The number of host pool addresses. + virtual size_t address_count() const NOEXCEPT; + + protected: /// Constructors. diff --git a/src/full_node.cpp b/src/full_node.cpp index 872c10b3..e098102d 100644 --- a/src/full_node.cpp +++ b/src/full_node.cpp @@ -447,6 +447,11 @@ time_t full_node::start_time() const NOEXCEPT // Methods. // ---------------------------------------------------------------------------- +void full_node::fetch(network::address_handler&& handler) NOEXCEPT +{ + network::net::fetch(std::move(handler)); +} + void full_node::estimate(size_t target, estimator::mode mode, estimate_handler&& handler) NOEXCEPT { diff --git a/src/protocols/protocol.cpp b/src/protocols/protocol.cpp index 90a85c3d..4a86fe87 100644 --- a/src/protocols/protocol.cpp +++ b/src/protocols/protocol.cpp @@ -93,6 +93,52 @@ void protocol::estimate(size_t target, estimator::mode mode, // Events subscription. // ---------------------------------------------------------------------------- +size_t protocol::address_count() const NOEXCEPT +{ + return session_->address_count(); +} + +void protocol::fetch_addresses( + network::address_handler&& handler) const NOEXCEPT +{ + session_->fetch_addresses(std::move(handler)); +} + +void protocol::connect(const network::config::endpoint& endpoint) NOEXCEPT +{ + session_->connect(endpoint); +} + +bool protocol::suspended() const NOEXCEPT +{ + return session_->suspended(); +} + +void protocol::suspend(const code& ec) NOEXCEPT +{ + session_->suspend(ec); +} + +void protocol::resume() NOEXCEPT +{ + session_->resume(); +} + +// Organizers. +// ---------------------------------------------------------------------------- + +void protocol::organize(const system::chain::header::cptr& header, + organize_handler&& handler) NOEXCEPT +{ + session_->organize(header, std::move(handler)); +} + +void protocol::organize(const system::chain::block::cptr& block, + organize_handler&& handler) NOEXCEPT +{ + session_->organize(block, std::move(handler)); +} + void protocol::subscribe_chase(event_notifier&& handler) NOEXCEPT { // This is a shared instance multiply-derived from network::protocol. diff --git a/src/protocols/protocol_peer.cpp b/src/protocols/protocol_peer.cpp index b595400d..e67b88f4 100644 --- a/src/protocols/protocol_peer.cpp +++ b/src/protocols/protocol_peer.cpp @@ -29,18 +29,6 @@ using namespace network; // Organizers. // ---------------------------------------------------------------------------- -void protocol_peer::organize(const system::chain::header::cptr& header, - organize_handler&& handler) NOEXCEPT -{ - session_->organize(header, std::move(handler)); -} - -void protocol_peer::organize(const system::chain::block::cptr& block, - organize_handler&& handler) NOEXCEPT -{ - session_->organize(block, std::move(handler)); -} - void protocol_peer::get_hashes(map_handler&& handler) NOEXCEPT { session_->get_hashes(std::move(handler)); diff --git a/src/sessions/session.cpp b/src/sessions/session.cpp index 933d5c8b..c81e2297 100644 --- a/src/sessions/session.cpp +++ b/src/sessions/session.cpp @@ -175,6 +175,37 @@ size_t session::inbound_channel_count() const NOEXCEPT return node_.inbound_channel_count(); } +size_t session::address_count() const NOEXCEPT +{ + return node_.address_count(); +} + +void session::fetch_addresses( + network::address_handler&& handler) const NOEXCEPT +{ + node_.fetch(std::move(handler)); +} + +void session::connect(const network::config::endpoint& endpoint) NOEXCEPT +{ + node_.connect(endpoint); +} + +bool session::suspended() const NOEXCEPT +{ + return node_.suspended(); +} + +void session::suspend(const code& ec) NOEXCEPT +{ + node_.suspend(ec); +} + +void session::resume() NOEXCEPT +{ + node_.resume(); +} + BC_POP_WARNING() } // namespace node