From 35eaebbe8b0a16c4267485a934d447f799bdf510 Mon Sep 17 00:00:00 2001 From: evoskuil Date: Sun, 21 Dec 2025 02:04:53 -0500 Subject: [PATCH 1/3] Comments. --- include/bitcoin/network/channels/channel_http.hpp | 8 ++++---- include/bitcoin/network/channels/channel_rpc.hpp | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/bitcoin/network/channels/channel_http.hpp b/include/bitcoin/network/channels/channel_http.hpp index 724146432..103ab3846 100644 --- a/include/bitcoin/network/channels/channel_http.hpp +++ b/include/bitcoin/network/channels/channel_http.hpp @@ -33,7 +33,7 @@ namespace libbitcoin { namespace network { -/// Half-duplex reading of http-request and sending of http-response. +/// Half-duplex reading/writing of http-request/response. class BCT_API channel_http : public channel { @@ -43,7 +43,7 @@ class BCT_API channel_http using interface = rpc::interface::http; using dispatcher = rpc::dispatcher; - /// Subscribe to request from peer (requires strand). + /// Subscribe to request from client (requires strand). /// Event handler is always invoked on the channel strand. template inline void subscribe(auto&& handler) NOEXCEPT @@ -71,7 +71,7 @@ class BCT_API channel_http /// Must call after successful message handling if no stop. virtual void receive() NOEXCEPT; - /// Serialize and write http response to peer (requires strand). + /// Serialize and write http response to client (requires strand). /// Completion handler is always invoked on the channel strand. virtual void send(http::response&& response, result_handler&& handler) NOEXCEPT; @@ -89,7 +89,7 @@ class BCT_API channel_http /// Size and assign response_buffer_ if value type is json or json-rpc. virtual void assign_json_buffer(http::response& response) NOEXCEPT; - // Handlers. + /// Handlers. virtual void handle_receive(const code& ec, size_t bytes, const http::request_cptr& request) NOEXCEPT; virtual void handle_send(const code& ec, size_t bytes, http::response_ptr&, diff --git a/include/bitcoin/network/channels/channel_rpc.hpp b/include/bitcoin/network/channels/channel_rpc.hpp index 8e78676d8..72bdd944c 100644 --- a/include/bitcoin/network/channels/channel_rpc.hpp +++ b/include/bitcoin/network/channels/channel_rpc.hpp @@ -28,7 +28,7 @@ namespace libbitcoin { namespace network { -/// rpc over tcp channel. +/// Read rpc-request and send rpc-response. class BCT_API channel_rpc : public channel { From 28ae41668a95c4a432e8a7ed4867edfb276e4078 Mon Sep 17 00:00:00 2001 From: evoskuil Date: Sun, 21 Dec 2025 02:04:57 -0500 Subject: [PATCH 2/3] Stub in channel_rpc methods. --- .../bitcoin/network/channels/channel_rpc.hpp | 10 ++++++++++ src/channels/channel_rpc.cpp | 17 +++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/include/bitcoin/network/channels/channel_rpc.hpp b/include/bitcoin/network/channels/channel_rpc.hpp index 72bdd944c..3c8d086af 100644 --- a/include/bitcoin/network/channels/channel_rpc.hpp +++ b/include/bitcoin/network/channels/channel_rpc.hpp @@ -41,6 +41,16 @@ class BCT_API channel_rpc : channel(log, socket, identifier, settings, options) { } + + /// Resume reading from the socket (requires strand). + void resume() NOEXCEPT override; + + /// Must call after successful message handling if no stop. + virtual void receive() NOEXCEPT; + + /// Serialize and write rpc response to client (requires strand). + /// Completion handler is always invoked on the channel strand. + virtual void send() NOEXCEPT; }; } // namespace network diff --git a/src/channels/channel_rpc.cpp b/src/channels/channel_rpc.cpp index fe47d4c90..01a85c507 100644 --- a/src/channels/channel_rpc.cpp +++ b/src/channels/channel_rpc.cpp @@ -23,5 +23,22 @@ namespace libbitcoin { namespace network { +void channel_rpc::resume() NOEXCEPT +{ + BC_ASSERT(stranded()); + channel::resume(); + receive(); +} + +void channel_rpc::receive() NOEXCEPT +{ + BC_ASSERT(stranded()); +} + +void channel_rpc::send() NOEXCEPT +{ + BC_ASSERT(stranded()); +} + } // namespace network } // namespace libbitcoin From 84f62d78abf368d63745cf1e1701e6cba30726b2 Mon Sep 17 00:00:00 2001 From: evoskuil Date: Thu, 25 Dec 2025 17:29:33 -0500 Subject: [PATCH 3/3] Make protocol_http::startO() public. --- include/bitcoin/network/protocols/protocol_http.hpp | 4 ++-- src/protocols/protocol_http.cpp | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/include/bitcoin/network/protocols/protocol_http.hpp b/include/bitcoin/network/protocols/protocol_http.hpp index ccb283a8d..919bd89f1 100644 --- a/include/bitcoin/network/protocols/protocol_http.hpp +++ b/include/bitcoin/network/protocols/protocol_http.hpp @@ -47,12 +47,12 @@ class BCT_API protocol_http using channel_t = channel_http; using options_t = channel_t::options_t; + void start() NOEXCEPT override; + protected: protocol_http(const session::ptr& session, const channel::ptr& channel, const options_t& options) NOEXCEPT; - void start() NOEXCEPT override; - DECLARE_SEND(); DECLARE_SUBSCRIBE_CHANNEL(); diff --git a/src/protocols/protocol_http.cpp b/src/protocols/protocol_http.cpp index 380bf8662..a593ffe21 100644 --- a/src/protocols/protocol_http.cpp +++ b/src/protocols/protocol_http.cpp @@ -58,6 +58,7 @@ protocol_http::protocol_http(const session::ptr& session, // Start. // ---------------------------------------------------------------------------- +// public void protocol_http::start() NOEXCEPT { BC_ASSERT(stranded());