diff --git a/include/bitcoin/network/impl/channels/channel_rpc.ipp b/include/bitcoin/network/impl/channels/channel_rpc.ipp index aef8c4eda..1bd74643d 100644 --- a/include/bitcoin/network/impl/channels/channel_rpc.ipp +++ b/include/bitcoin/network/impl/channels/channel_rpc.ipp @@ -170,10 +170,10 @@ inline rpc::message_ptr CLASS::assign_message(Message&& message, size_t size_hint) NOEXCEPT { BC_ASSERT(stranded()); - response_buffer_->max_size(size_hint); const auto ptr = system::to_shared>(); ptr->message = std::move(message); ptr->buffer = response_buffer_; + ptr->size_hint = size_hint; return ptr; } diff --git a/include/bitcoin/network/impl/messages/json_body.ipp b/include/bitcoin/network/impl/messages/json_body.ipp index 7689a6448..0fe458ebb 100644 --- a/include/bitcoin/network/impl/messages/json_body.ipp +++ b/include/bitcoin/network/impl/messages/json_body.ipp @@ -133,15 +133,20 @@ TEMPLATE void CLASS::writer::init(boost_code& ec) NOEXCEPT { using namespace system; + const auto size = is_zero(value_.size_hint) ? default_buffer : + value_.size_hint; + + // Reuse is unsafe except for half duplex. if (!value_.buffer) { - // Caller controls max_size and other buffer behavior by assigning it. - value_.buffer = emplace_shared(default_buffer); + // Caller controls buffer lifetime by assigning it (less allocation). + value_.buffer = emplace_shared(size); } else { // Caller has assigned the buffer (or just reused the response). value_.buffer->consume(value_.buffer->size()); + value_.buffer->max_size(size); } ec.clear(); diff --git a/include/bitcoin/network/messages/peer/enums/level.hpp b/include/bitcoin/network/messages/peer/enums/level.hpp index 92af02a60..12b0fd370 100644 --- a/include/bitcoin/network/messages/peer/enums/level.hpp +++ b/include/bitcoin/network/messages/peer/enums/level.hpp @@ -171,12 +171,15 @@ enum level: uint32_t /// send_address_v2 bip155 = 70016, - /// wtxidrelay - bip339 = 70016, - /// erlay [not supported] bip330 = 70016, + /// pkgtxns (requires wtxidrelay) + bip331 = 70016, + + /// wtxidrelay + bip339 = 70016, + /// ----------------------------------------------------------------------- /// We require at least this of peers (for current address structure).