From 0cb66c3c0f766630f5fb237c1d14887344c70ece Mon Sep 17 00:00:00 2001 From: Eric Voskuil Date: Sat, 22 Aug 2026 23:35:27 -0400 Subject: [PATCH 1/4] Hoist organize passthroughs to node protocol base. --- include/bitcoin/node/protocols/protocol.hpp | 11 +++++++++++ include/bitcoin/node/protocols/protocol_peer.hpp | 8 -------- src/protocols/protocol.cpp | 15 +++++++++++++++ src/protocols/protocol_peer.cpp | 12 ------------ 4 files changed, 26 insertions(+), 20 deletions(-) diff --git a/include/bitcoin/node/protocols/protocol.hpp b/include/bitcoin/node/protocols/protocol.hpp index 3a7d4cc9..7e24fb38 100644 --- a/include/bitcoin/node/protocols/protocol.hpp +++ b/include/bitcoin/node/protocols/protocol.hpp @@ -84,6 +84,17 @@ class BCN_API protocol void estimate(size_t target, estimator::mode mode, estimate_handler&& handler) 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/src/protocols/protocol.cpp b/src/protocols/protocol.cpp index 90a85c3d..bbc9ebc0 100644 --- a/src/protocols/protocol.cpp +++ b/src/protocols/protocol.cpp @@ -93,6 +93,21 @@ void protocol::estimate(size_t target, estimator::mode mode, // Events subscription. // ---------------------------------------------------------------------------- +// 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)); From 0b9b88d0c5dbaadfc16f6842bb695a4102d3ba02 Mon Sep 17 00:00:00 2001 From: Eric Voskuil Date: Sat, 22 Aug 2026 23:49:14 -0400 Subject: [PATCH 2/4] Add address and suspension passthroughs to node protocol. --- include/bitcoin/node/full_node.hpp | 3 +++ include/bitcoin/node/protocols/protocol.hpp | 12 ++++++++++ include/bitcoin/node/sessions/session.hpp | 12 ++++++++++ src/protocols/protocol.cpp | 26 +++++++++++++++++++++ src/sessions/session.cpp | 26 +++++++++++++++++++++ 5 files changed, 79 insertions(+) diff --git a/include/bitcoin/node/full_node.hpp b/include/bitcoin/node/full_node.hpp index 25f81579..330743fe 100644 --- a/include/bitcoin/node/full_node.hpp +++ b/include/bitcoin/node/full_node.hpp @@ -101,6 +101,9 @@ class BCN_API full_node /// Resume nework connections. void resume() NOEXCEPT override; + /// Expose the host pool fetch for administrative queries. + using network::net::fetch; + /// Suspend all existing and future network connections. /// A race condition can result in an unsuspended connection. void suspend(const code& ec) NOEXCEPT override; diff --git a/include/bitcoin/node/protocols/protocol.hpp b/include/bitcoin/node/protocols/protocol.hpp index 7e24fb38..738dbf91 100644 --- a/include/bitcoin/node/protocols/protocol.hpp +++ b/include/bitcoin/node/protocols/protocol.hpp @@ -77,6 +77,18 @@ 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; + + /// Fetch a copy of the host pool addresses. + virtual void fetch_addresses( + network::address_handler&& handler) const NOEXCEPT; + + /// Network suspension (does not affect administrative connections). + virtual bool suspended() const NOEXCEPT; + virtual void suspend(const code& ec) NOEXCEPT; + virtual void resume() NOEXCEPT; + /// Methods. /// ----------------------------------------------------------------------- diff --git a/include/bitcoin/node/sessions/session.hpp b/include/bitcoin/node/sessions/session.hpp index 8b0772f6..c17806b3 100644 --- a/include/bitcoin/node/sessions/session.hpp +++ b/include/bitcoin/node/sessions/session.hpp @@ -118,6 +118,18 @@ 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; + + /// Fetch a copy of the host pool addresses. + virtual void fetch_addresses( + network::address_handler&& handler) const NOEXCEPT; + + /// Network suspension (does not affect administrative connections). + virtual bool suspended() const NOEXCEPT; + virtual void suspend(const code& ec) NOEXCEPT; + virtual void resume() NOEXCEPT; + protected: /// Constructors. diff --git a/src/protocols/protocol.cpp b/src/protocols/protocol.cpp index bbc9ebc0..eb274ece 100644 --- a/src/protocols/protocol.cpp +++ b/src/protocols/protocol.cpp @@ -93,6 +93,32 @@ 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)); +} + +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. // ---------------------------------------------------------------------------- diff --git a/src/sessions/session.cpp b/src/sessions/session.cpp index 933d5c8b..395c7322 100644 --- a/src/sessions/session.cpp +++ b/src/sessions/session.cpp @@ -175,6 +175,32 @@ 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)); +} + +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 From d583cbac6b8aa2f7b9f79be61486a7c0dd3caa72 Mon Sep 17 00:00:00 2001 From: Eric Voskuil Date: Sat, 22 Aug 2026 23:57:47 -0400 Subject: [PATCH 3/4] Add manual connect passthrough to node protocol. --- include/bitcoin/node/protocols/protocol.hpp | 3 +++ include/bitcoin/node/sessions/session.hpp | 3 +++ src/protocols/protocol.cpp | 5 +++++ src/sessions/session.cpp | 5 +++++ 4 files changed, 16 insertions(+) diff --git a/include/bitcoin/node/protocols/protocol.hpp b/include/bitcoin/node/protocols/protocol.hpp index 738dbf91..b08338ec 100644 --- a/include/bitcoin/node/protocols/protocol.hpp +++ b/include/bitcoin/node/protocols/protocol.hpp @@ -84,6 +84,9 @@ class BCN_API protocol 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; + /// Network suspension (does not affect administrative connections). virtual bool suspended() const NOEXCEPT; virtual void suspend(const code& ec) NOEXCEPT; diff --git a/include/bitcoin/node/sessions/session.hpp b/include/bitcoin/node/sessions/session.hpp index c17806b3..51bdd846 100644 --- a/include/bitcoin/node/sessions/session.hpp +++ b/include/bitcoin/node/sessions/session.hpp @@ -125,6 +125,9 @@ class BCN_API session 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; + /// Network suspension (does not affect administrative connections). virtual bool suspended() const NOEXCEPT; virtual void suspend(const code& ec) NOEXCEPT; diff --git a/src/protocols/protocol.cpp b/src/protocols/protocol.cpp index eb274ece..4a86fe87 100644 --- a/src/protocols/protocol.cpp +++ b/src/protocols/protocol.cpp @@ -104,6 +104,11 @@ void protocol::fetch_addresses( 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(); diff --git a/src/sessions/session.cpp b/src/sessions/session.cpp index 395c7322..c81e2297 100644 --- a/src/sessions/session.cpp +++ b/src/sessions/session.cpp @@ -186,6 +186,11 @@ void session::fetch_addresses( 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(); From 2172485f87b0f5bc8eb8d49b580885969d9ca1f7 Mon Sep 17 00:00:00 2001 From: Eric Voskuil Date: Sun, 23 Aug 2026 23:21:19 -0400 Subject: [PATCH 4/4] Method organization. --- include/bitcoin/node/full_node.hpp | 6 +++--- include/bitcoin/node/protocols/protocol.hpp | 17 ++++++++------- include/bitcoin/node/sessions/session.hpp | 23 +++++++++++---------- src/full_node.cpp | 5 +++++ 4 files changed, 30 insertions(+), 21 deletions(-) diff --git a/include/bitcoin/node/full_node.hpp b/include/bitcoin/node/full_node.hpp index 330743fe..71068757 100644 --- a/include/bitcoin/node/full_node.hpp +++ b/include/bitcoin/node/full_node.hpp @@ -101,9 +101,6 @@ class BCN_API full_node /// Resume nework connections. void resume() NOEXCEPT override; - /// Expose the host pool fetch for administrative queries. - using network::net::fetch; - /// Suspend all existing and future network connections. /// A race condition can result in an unsuspended connection. void suspend(const code& ec) NOEXCEPT override; @@ -154,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 b08338ec..946310b6 100644 --- a/include/bitcoin/node/protocols/protocol.hpp +++ b/include/bitcoin/node/protocols/protocol.hpp @@ -80,6 +80,9 @@ class BCN_API protocol /// 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; @@ -87,18 +90,18 @@ class BCN_API protocol /// 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; - /// Methods. - /// ----------------------------------------------------------------------- - - /// Get current fee estimate. - void estimate(size_t target, estimator::mode mode, - estimate_handler&& handler) NOEXCEPT; - /// Organizers. /// ----------------------------------------------------------------------- diff --git a/include/bitcoin/node/sessions/session.hpp b/include/bitcoin/node/sessions/session.hpp index 51bdd846..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; @@ -121,17 +133,6 @@ class BCN_API session /// The number of host pool addresses. virtual size_t address_count() const NOEXCEPT; - /// 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; - - /// Network suspension (does not affect administrative connections). - virtual bool suspended() const NOEXCEPT; - virtual void suspend(const code& ec) NOEXCEPT; - virtual void resume() NOEXCEPT; protected: 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 {