From fe2bb57d1ec30d5a45264901d933f55bc6f07da7 Mon Sep 17 00:00:00 2001 From: evoskuil Date: Tue, 3 Mar 2026 19:34:30 -0500 Subject: [PATCH] Comments on json-rpc batch implementation. --- include/bitcoin/network/impl/channels/channel_rpc.ipp | 8 ++++++++ src/channels/channel_http.cpp | 6 ++++++ src/messages/rpc/body.cpp | 1 + 3 files changed, 15 insertions(+) diff --git a/include/bitcoin/network/impl/channels/channel_rpc.ipp b/include/bitcoin/network/impl/channels/channel_rpc.ipp index 8dfbd9b9b..26018479f 100644 --- a/include/bitcoin/network/impl/channels/channel_rpc.ipp +++ b/include/bitcoin/network/impl/channels/channel_rpc.ipp @@ -103,6 +103,14 @@ inline void CLASS::handle_receive(const code& ec, size_t bytes, return; } + // TODO: Extend support to batch (array of rpc). + // TODO: This would consist of asynchronous recursion here, with iteration + // TODO: over the message array. The response is accumulated, but there is + // TODO: no way we would buffer it at the server until complete, which is a + // TODO: clear DoS vector. We would instead track the iteration and send + // TODO: each response with the necessary delimiters. This allows a request + // TODO: to safely be of any configured byte size or request element count. + // Save response state. identity_ = request->message.id; version_ = request->message.jsonrpc; diff --git a/src/channels/channel_http.cpp b/src/channels/channel_http.cpp index 10e87fba3..369851819 100644 --- a/src/channels/channel_http.cpp +++ b/src/channels/channel_http.cpp @@ -75,6 +75,12 @@ void channel_http::receive() NOEXCEPT if (stopped() || paused() || reading_) return; + // TODO: Extend support to batch (array of rpc). + // TODO: See notes in channel_rpc.ipp. This is the same except there must + // TODO: be an set of socket methods for incremental http-rpc. This can + // TODO: be handled by writing the header, whole rpc responses, and close. + // TODO: Boost beast provides these independent async calls for chunking. + reading_ = true; const auto in = to_shared(); diff --git a/src/messages/rpc/body.cpp b/src/messages/rpc/body.cpp index 70264f7cd..3a3f9f430 100644 --- a/src/messages/rpc/body.cpp +++ b/src/messages/rpc/body.cpp @@ -105,6 +105,7 @@ finish(boost_code& ec) NOEXCEPT try { + // TODO: extend support to batch (array of rpc). value_.message = value_to(value_.model); value_.model.emplace_null(); }