diff --git a/builds/gnu/Makefile.am b/builds/gnu/Makefile.am
index 312a73fb2..fb46f5db8 100644
--- a/builds/gnu/Makefile.am
+++ b/builds/gnu/Makefile.am
@@ -336,8 +336,7 @@ include_bitcoin_network_interfaces_HEADERS = \
${srcdir}/../../include/bitcoin/network/interfaces/http.hpp \
${srcdir}/../../include/bitcoin/network/interfaces/interfaces.hpp \
${srcdir}/../../include/bitcoin/network/interfaces/peer_broadcast.hpp \
- ${srcdir}/../../include/bitcoin/network/interfaces/peer_dispatch.hpp \
- ${srcdir}/../../include/bitcoin/network/interfaces/peer_registry.hpp
+ ${srcdir}/../../include/bitcoin/network/interfaces/peer_dispatch.hpp
include_bitcoin_network_logdir = \
${includedir}/bitcoin/network/log
@@ -385,7 +384,8 @@ include_bitcoin_network_messages_peer_HEADERS = \
${srcdir}/../../include/bitcoin/network/messages/peer/body.hpp \
${srcdir}/../../include/bitcoin/network/messages/peer/heading.hpp \
${srcdir}/../../include/bitcoin/network/messages/peer/message.hpp \
- ${srcdir}/../../include/bitcoin/network/messages/peer/peer.hpp
+ ${srcdir}/../../include/bitcoin/network/messages/peer/peer.hpp \
+ ${srcdir}/../../include/bitcoin/network/messages/peer/registry.hpp
include_bitcoin_network_messages_peer_detaildir = \
${includedir}/bitcoin/network/messages/peer/detail
diff --git a/builds/msvc/vs2022/libbitcoin-network/libbitcoin-network.vcxproj b/builds/msvc/vs2022/libbitcoin-network/libbitcoin-network.vcxproj
index 229525423..06c706d1c 100644
--- a/builds/msvc/vs2022/libbitcoin-network/libbitcoin-network.vcxproj
+++ b/builds/msvc/vs2022/libbitcoin-network/libbitcoin-network.vcxproj
@@ -347,7 +347,6 @@
-
@@ -415,6 +414,7 @@
+
diff --git a/builds/msvc/vs2022/libbitcoin-network/libbitcoin-network.vcxproj.filters b/builds/msvc/vs2022/libbitcoin-network/libbitcoin-network.vcxproj.filters
index 8f1713940..e626e0f55 100644
--- a/builds/msvc/vs2022/libbitcoin-network/libbitcoin-network.vcxproj.filters
+++ b/builds/msvc/vs2022/libbitcoin-network/libbitcoin-network.vcxproj.filters
@@ -779,9 +779,6 @@
include\bitcoin\network\interfaces
-
- include\bitcoin\network\interfaces
-
include\bitcoin\network\log
@@ -983,6 +980,9 @@
include\bitcoin\network\messages\peer
+
+ include\bitcoin\network\messages\peer
+
include\bitcoin\network\messages\rpc
diff --git a/builds/msvc/vs2026/libbitcoin-network/libbitcoin-network.vcxproj b/builds/msvc/vs2026/libbitcoin-network/libbitcoin-network.vcxproj
index 5953989a5..e87b58b16 100644
--- a/builds/msvc/vs2026/libbitcoin-network/libbitcoin-network.vcxproj
+++ b/builds/msvc/vs2026/libbitcoin-network/libbitcoin-network.vcxproj
@@ -347,7 +347,6 @@
-
@@ -415,6 +414,7 @@
+
diff --git a/builds/msvc/vs2026/libbitcoin-network/libbitcoin-network.vcxproj.filters b/builds/msvc/vs2026/libbitcoin-network/libbitcoin-network.vcxproj.filters
index 8f1713940..e626e0f55 100644
--- a/builds/msvc/vs2026/libbitcoin-network/libbitcoin-network.vcxproj.filters
+++ b/builds/msvc/vs2026/libbitcoin-network/libbitcoin-network.vcxproj.filters
@@ -779,9 +779,6 @@
include\bitcoin\network\interfaces
-
- include\bitcoin\network\interfaces
-
include\bitcoin\network\log
@@ -983,6 +980,9 @@
include\bitcoin\network\messages\peer
+
+ include\bitcoin\network\messages\peer
+
include\bitcoin\network\messages\rpc
diff --git a/include/bitcoin/network.hpp b/include/bitcoin/network.hpp
index 6e5ad185f..65676973c 100644
--- a/include/bitcoin/network.hpp
+++ b/include/bitcoin/network.hpp
@@ -57,7 +57,6 @@
#include
#include
#include
-#include
#include
#include
#include
@@ -81,6 +80,7 @@
#include
#include
#include
+#include
#include
#include
#include
diff --git a/include/bitcoin/network/channels/channel_http.hpp b/include/bitcoin/network/channels/channel_http.hpp
index fecd896fe..705439905 100644
--- a/include/bitcoin/network/channels/channel_http.hpp
+++ b/include/bitcoin/network/channels/channel_http.hpp
@@ -106,8 +106,11 @@ class BCT_API channel_http
/// Read request buffer (requires strand).
virtual http::flat_buffer& request_buffer() NOEXCEPT;
- /// Override to set default websocket reader body.
- virtual http::body::value_type websocket_body() const NOEXCEPT;
+ /// Override to set the preselected reader body.
+ virtual http::body::value_type default_body() const NOEXCEPT;
+
+ /// Override to tolerate json-rpc single value params (electrum laxness).
+ virtual bool lax_params() const NOEXCEPT;
/// Latch authorization from request headers (requires strand).
virtual void set_authorized(const http::request& request) NOEXCEPT;
diff --git a/include/bitcoin/network/channels/channel_peer.hpp b/include/bitcoin/network/channels/channel_peer.hpp
index 62137ac49..6db4bf4f0 100644
--- a/include/bitcoin/network/channels/channel_peer.hpp
+++ b/include/bitcoin/network/channels/channel_peer.hpp
@@ -25,6 +25,7 @@
#include
#include
#include
+#include
namespace libbitcoin {
namespace network {
@@ -65,7 +66,7 @@ class BCT_API channel_peer
out.magic = settings().identifier;
out.version = negotiated_version();
out.message = rpc::any_t{ system::to_shared(message) };
- out.index = rpc::peer_registry::index_of();
+ out.index = messages::peer::registry::index_of();
LOGX("Send " << Message::command << " to [" << endpoint() << "] ("
<< message.size(out.version) << " bytes)");
diff --git a/include/bitcoin/network/interfaces/interfaces.hpp b/include/bitcoin/network/interfaces/interfaces.hpp
index 396e1ba4d..c636703fa 100644
--- a/include/bitcoin/network/interfaces/interfaces.hpp
+++ b/include/bitcoin/network/interfaces/interfaces.hpp
@@ -22,7 +22,6 @@
#include
#include
#include
-#include
namespace libbitcoin {
namespace network {
@@ -33,8 +32,10 @@ using http = publish;
namespace peer {
-using dispatch = publish;
-using broadcast = publish;
+using dispatch = publish;
+using broadcast = publish;
} // namespace peer
} // namespace interface
diff --git a/include/bitcoin/network/interfaces/peer_broadcast.hpp b/include/bitcoin/network/interfaces/peer_broadcast.hpp
index aeef26d5a..883a8eac5 100644
--- a/include/bitcoin/network/interfaces/peer_broadcast.hpp
+++ b/include/bitcoin/network/interfaces/peer_broadcast.hpp
@@ -42,6 +42,7 @@ struct peer_broadcast
using signature = std::function;
+ /// Methods (exchanged after the handshake completes).
static constexpr std::tuple methods
{
method<"addr", messages::peer::address::cptr, key>{},
@@ -72,14 +73,22 @@ struct peer_broadcast
method<"ping", messages::peer::ping::cptr, key>{},
method<"pong", messages::peer::pong::cptr, key>{},
method<"reject", messages::peer::reject::cptr, key>{},
- method<"sendaddrv2", messages::peer::send_address_v2::cptr, key>{},
method<"sendcmpct", messages::peer::send_compact::cptr, key>{},
method<"sendheaders", messages::peer::send_headers::cptr, key>{},
- method<"tx", messages::peer::transaction::cptr, key>{},
+ method<"tx", messages::peer::transaction::cptr, key>{}
+ };
+
+ /// Handshake methods (exchanged before the handshake completes).
+ static constexpr std::tuple handshake
+ {
method<"version", messages::peer::version::cptr, key>{},
method<"verack", messages::peer::version_acknowledge::cptr, key>{},
+ method<"sendaddrv2", messages::peer::send_address_v2::cptr, key>{},
method<"wtxidrelay", messages::peer::witness_tx_id_relay::cptr, key>{}
};
+
+ /// All methods (the channel dispatches on the union).
+ static constexpr auto all = std::tuple_cat(handshake, methods);
};
} // namespace rpc
diff --git a/include/bitcoin/network/interfaces/peer_dispatch.hpp b/include/bitcoin/network/interfaces/peer_dispatch.hpp
index 45b15261a..ffea42612 100644
--- a/include/bitcoin/network/interfaces/peer_dispatch.hpp
+++ b/include/bitcoin/network/interfaces/peer_dispatch.hpp
@@ -38,6 +38,7 @@ struct peer_dispatch
using signature = std::function;
+ /// Methods (exchanged after the handshake completes).
static constexpr std::tuple methods
{
method<"addr", messages::peer::address::cptr>{},
@@ -68,14 +69,22 @@ struct peer_dispatch
method<"ping", messages::peer::ping::cptr>{},
method<"pong", messages::peer::pong::cptr>{},
method<"reject", messages::peer::reject::cptr>{},
- method<"sendaddrv2", messages::peer::send_address_v2::cptr>{},
method<"sendcmpct", messages::peer::send_compact::cptr>{},
method<"sendheaders", messages::peer::send_headers::cptr>{},
- method<"tx", messages::peer::transaction::cptr>{},
+ method<"tx", messages::peer::transaction::cptr>{}
+ };
+
+ /// Handshake methods (exchanged before the handshake completes).
+ static constexpr std::tuple handshake
+ {
method<"version", messages::peer::version::cptr>{},
method<"verack", messages::peer::version_acknowledge::cptr>{},
+ method<"sendaddrv2", messages::peer::send_address_v2::cptr>{},
method<"wtxidrelay", messages::peer::witness_tx_id_relay::cptr>{}
};
+
+ /// All methods (the channel dispatches on the union).
+ static constexpr auto all = std::tuple_cat(handshake, methods);
};
} // namespace rpc
diff --git a/include/bitcoin/network/interfaces/peer_registry.hpp b/include/bitcoin/network/messages/peer/registry.hpp
similarity index 79%
rename from include/bitcoin/network/interfaces/peer_registry.hpp
rename to include/bitcoin/network/messages/peer/registry.hpp
index a0c1f676e..b90771b95 100644
--- a/include/bitcoin/network/interfaces/peer_registry.hpp
+++ b/include/bitcoin/network/messages/peer/registry.hpp
@@ -16,23 +16,24 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see .
*/
-#ifndef LIBBITCOIN_NETWORK_INTERFACES_PEER_REGISTRY_HPP
-#define LIBBITCOIN_NETWORK_INTERFACES_PEER_REGISTRY_HPP
+#ifndef LIBBITCOIN_NETWORK_MESSAGES_PEER_REGISTRY_HPP
+#define LIBBITCOIN_NETWORK_MESSAGES_PEER_REGISTRY_HPP
#include
#include
#include
#include
-#include
+#include
namespace libbitcoin {
namespace network {
-namespace rpc {
+namespace messages {
+namespace peer {
-/// The peer message set, derived from the dispatch interface.
-struct peer_registry
+/// The peer message codec, derived from the dispatch interface.
+struct registry
{
- using methods_t = decltype(peer_dispatch::methods);
+ using methods_t = decltype(rpc::peer_dispatch::all);
static constexpr auto size = std::tuple_size_v;
/// Index of an unregistered command (one past the last valid index).
@@ -40,7 +41,7 @@ struct peer_registry
/// The message type registered at index.
template
- using arguments_t = args_native_t>;
+ using arguments_t = rpc::args_native_t>;
template
using cptr_t = std::tuple_element_t>;
template
@@ -48,7 +49,7 @@ struct peer_registry
/// The wire command registered at index.
template
- static constexpr auto command = method_t::name;
+ static constexpr auto command = rpc::method_t::name;
/// The numeric identifier registered at index.
template
@@ -59,15 +60,15 @@ struct peer_registry
private:
using span_t = std::span;
- using deserializer_t = any_t(*)(const span_t&, uint32_t, bool);
+ using deserializer_t = rpc::any_t(*)(const span_t&, uint32_t, bool);
using deserializers_t = std::array;
- using serializer_t = system::chunk_ptr(*)(const any_t&, uint32_t, uint32_t);
+ using serializer_t = system::chunk_ptr(*)(const rpc::any_t&, uint32_t, uint32_t);
using serializers_t = std::array;
- using payloader_t = system::chunk_ptr(*)(const any_t&, uint32_t);
+ using payloader_t = system::chunk_ptr(*)(const rpc::any_t&, uint32_t);
using payloaders_t = std::array;
template
- static any_t deserialize(const span_t& data, uint32_t version,
+ static rpc::any_t deserialize(const span_t& data, uint32_t version,
bool witness) NOEXCEPT
{
using message = message_t;
@@ -78,24 +79,24 @@ struct peer_registry
else
message_ptr = message::deserialize(version, data);
- return message_ptr ? any_t{ message_ptr } : any_t{};
+ return message_ptr ? rpc::any_t{ message_ptr } : rpc::any_t{};
}
template
- static system::chunk_ptr serialize(const any_t& message, uint32_t magic,
+ static system::chunk_ptr serialize(const rpc::any_t& message, uint32_t magic,
uint32_t version) NOEXCEPT
{
const auto ptr = message.get>();
- return ptr ? messages::peer::serialize(*ptr, magic, version) :
+ return ptr ? peer::serialize(*ptr, magic, version) :
system::chunk_ptr{};
}
template
- static system::chunk_ptr serialize_payload(const any_t& message,
+ static system::chunk_ptr serialize_payload(const rpc::any_t& message,
uint32_t version) NOEXCEPT
{
const auto ptr = message.get>();
- return ptr ? messages::peer::serialize(*ptr, version) :
+ return ptr ? peer::serialize(*ptr, version) :
system::chunk_ptr{};
}
@@ -103,14 +104,14 @@ struct peer_registry
static constexpr serializers_t make_serializers(
std::index_sequence) NOEXCEPT
{
- return { &peer_registry::serialize... };
+ return { ®istry::serialize... };
}
template
static constexpr payloaders_t make_payloaders(
std::index_sequence) NOEXCEPT
{
- return { &peer_registry::serialize_payload... };
+ return { ®istry::serialize_payload... };
}
template
@@ -146,7 +147,7 @@ struct peer_registry
static constexpr deserializers_t make_deserializers(
std::index_sequence) NOEXCEPT
{
- return { &peer_registry::deserialize... };
+ return { ®istry::deserialize... };
}
template
@@ -160,7 +161,7 @@ struct peer_registry
return same ? ((found = at), true) : false;
};
- (match(Index, peer_registry::command) || ...);
+ (match(Index, registry::command) || ...);
return found;
}
@@ -210,17 +211,17 @@ struct peer_registry
return to_index_of(std::make_index_sequence{});
}
- static any_t to_any(size_t index, const std::span& data,
+ static rpc::any_t to_any(size_t index, const std::span& data,
uint32_t version, bool witness) NOEXCEPT
{
static constexpr auto table = make_deserializers(
std::make_index_sequence{});
return index < size ? table.at(index)(data, version, witness) :
- any_t{};
+ rpc::any_t{};
}
- static system::chunk_ptr to_frame(size_t index, const any_t& message,
+ static system::chunk_ptr to_frame(size_t index, const rpc::any_t& message,
uint32_t magic, uint32_t version) NOEXCEPT
{
static constexpr auto table = make_serializers(
@@ -230,7 +231,7 @@ struct peer_registry
system::chunk_ptr{};
}
- static system::chunk_ptr to_payload(size_t index, const any_t& message,
+ static system::chunk_ptr to_payload(size_t index, const rpc::any_t& message,
uint32_t version) NOEXCEPT
{
static constexpr auto table = make_payloaders(
@@ -241,7 +242,8 @@ struct peer_registry
}
};
-} // namespace rpc
+} // namespace peer
+} // namespace messages
} // namespace network
} // namespace libbitcoin
diff --git a/include/bitcoin/network/messages/rpc/body.hpp b/include/bitcoin/network/messages/rpc/body.hpp
index 449087651..6d8984403 100644
--- a/include/bitcoin/network/messages/rpc/body.hpp
+++ b/include/bitcoin/network/messages/rpc/body.hpp
@@ -66,8 +66,8 @@ struct message_type
/// btcd non-standard v1 message within a (v2) batch.
bool lax_batch{};
- /// Socket wires message termination by transport framing (tcp/ws
- /// stream messages are newline terminated, http chunks are not).
+ /// Socket wires message termination by transport framing (tcp stream
+ /// messages are newline terminated, http/ws framed messages are not).
bool terminate{};
};
diff --git a/include/bitcoin/network/messages/rpc/publish.hpp b/include/bitcoin/network/messages/rpc/publish.hpp
index ce0d982af..04cb36cd8 100644
--- a/include/bitcoin/network/messages/rpc/publish.hpp
+++ b/include/bitcoin/network/messages/rpc/publish.hpp
@@ -30,11 +30,14 @@ namespace rpc {
/// Methods are a std::tuple of rpc::method.
/// Defines a published interface for use with rpc::dispatcher<>.
-template
+/// Tuple selects the published methods (e.g. a handshake subset).
+template
struct publish
: public Methods
{
- using type = decltype(Methods::methods);
+ static constexpr auto& methods = Tuple;
+ using type = std::remove_cvref_t;
static constexpr auto size = std::tuple_size_v;
static constexpr grouping mode = Mode;
};
diff --git a/include/bitcoin/network/net/proxy.hpp b/include/bitcoin/network/net/proxy.hpp
index 8e0c38036..9d3e4b048 100644
--- a/include/bitcoin/network/net/proxy.hpp
+++ b/include/bitcoin/network/net/proxy.hpp
@@ -108,6 +108,12 @@ class BCT_API proxy
/// The socket was upgraded to a websocket.
bool websocket() const NOEXCEPT;
+ /// Downgraded from http to tcp by the initial json-rpc request.
+ bool downgraded() const NOEXCEPT;
+
+ /// The transport has been detected (downgraded is otherwise undefined).
+ bool detected() const NOEXCEPT;
+
/// The total number of bytes queued/sent to the remote endpoint.
uint64_t total() const NOEXCEPT;
@@ -254,7 +260,19 @@ class BCT_API proxy
void handle_stop_write(const code& ec, size_t bytes,
const code& reason) NOEXCEPT;
+ // For http vs. tcp transport detection.
+ void handle_detect(const code& ec, size_t bytes,
+ const ref& request, const ref& buffer,
+ const count_handler& handler) NOEXCEPT;
+
// For rpc batch normalization (http).
+ void do_rpc_request_read(const ref& request,
+ const ref& buffer,
+ const count_handler& handler) NOEXCEPT;
+ void do_downgrade_read(const ref& request,
+ const ref& buffer,
+ const count_handler& handler) NOEXCEPT;
+
void do_http_request_read(const ref& request,
const ref& buffer,
const count_handler& handler) NOEXCEPT;
diff --git a/include/bitcoin/network/net/socket.hpp b/include/bitcoin/network/net/socket.hpp
index ca15e5b7b..25e3c2e27 100644
--- a/include/bitcoin/network/net/socket.hpp
+++ b/include/bitcoin/network/net/socket.hpp
@@ -190,6 +190,11 @@ class BCT_API socket
using http_parser = boost::beast::http::request_parser;
using http_parser_ptr = std::shared_ptr;
+ /// Latch http vs. tcp from buffered bytes, reading only as required to
+ /// decide, handler posted to socket strand. No message is consumed.
+ virtual void detect(http::flat_buffer& buffer,
+ count_handler&& handler) NOEXCEPT;
+
/// Read http request from the socket, handler posted to socket strand.
virtual void http_read(http::flat_buffer& buffer, http::request& request,
count_handler&& handler) NOEXCEPT;
@@ -252,6 +257,12 @@ class BCT_API socket
/// The socket was upgraded to a websocket.
virtual bool websocket() const NOEXCEPT;
+ /// Downgraded from http to tcp by the initial json-rpc request.
+ virtual bool downgraded() const NOEXCEPT;
+
+ /// The transport has been detected (downgraded is otherwise undefined).
+ virtual bool detected() const NOEXCEPT;
+
/// Get the address of the outgoing endpoint passed via construct, or the
/// resolved endpoint address for incoming connections.
virtual const config::address& address() const NOEXCEPT;
@@ -485,6 +496,10 @@ class BCT_API socket
void do_body_notify(boost_code ec, size_t total,
const notify_state::ptr& out, const count_handler& handler) NOEXCEPT;
+ // detect (first read)
+ void do_detect(const ref& buffer,
+ const count_handler& handler) NOEXCEPT;
+
// http
void do_http_read(ref buffer,
const ref& request,
@@ -561,6 +576,11 @@ class BCT_API socket
void handle_body_notify(const code& ec, size_t size, size_t total,
const notify_state::ptr& out, const count_handler& handler) NOEXCEPT;
+ // detect
+ void handle_detect(const code& ec, size_t size,
+ const ref& buffer,
+ const count_handler& handler) NOEXCEPT;
+
// http/ws (native/rpc)
void handle_http_read(const boost_code& ec, size_t size,
const ref& request, const http_parser_ptr& parser,
@@ -597,6 +617,8 @@ class BCT_API socket
const zmtp::role role_;
std::atomic_bool stopped_{};
std::atomic_bool websocket_{};
+ std::atomic_bool detected_{};
+ std::atomic_bool downgraded_{};
// These are protected by strand (see also handle_accept).
config::address address_;
diff --git a/include/bitcoin/network/protocols/protocol_http.hpp b/include/bitcoin/network/protocols/protocol_http.hpp
index 7d9c05506..82ddd7857 100644
--- a/include/bitcoin/network/protocols/protocol_http.hpp
+++ b/include/bitcoin/network/protocols/protocol_http.hpp
@@ -122,6 +122,7 @@ class BCT_API protocol_http
/// Properties.
uint16_t default_port() const NOEXCEPT;
bool websocket() const NOEXCEPT;
+ bool downgraded() const NOEXCEPT;
/// True if the authorized credential permits the rpc method.
bool permitted(const std::string& method) const NOEXCEPT;
diff --git a/src/channels/channel_http.cpp b/src/channels/channel_http.cpp
index 191e2c2b7..d73d95c75 100644
--- a/src/channels/channel_http.cpp
+++ b/src/channels/channel_http.cpp
@@ -140,8 +140,8 @@ void channel_http::handle_receive(const code& ec, size_t bytes,
LOGV(log_message(*request, bytes));
- // Websocket requests are synthesized (no headers).
- if (!websocket())
+ // Websocket and downgraded requests are synthesized (no headers).
+ if (!websocket() && !downgraded())
set_authorized(*request);
reading_ = false;
@@ -157,9 +157,9 @@ void channel_http::dispatch(const request_cptr& request) NOEXCEPT
// subsequent subscribers (e.g. a terminal default responder).
claimed_ = false;
- // Basic authorization is carried by http headers. ws frames carry none,
- // so ws authorization is dispatched to the protocol with the message.
- if (!websocket() && !authorized())
+ // Basic authorization is carried by http headers. ws frames and tcp
+ // messages carry none, so authorization is dispatched to the protocol.
+ if (!websocket() && !downgraded() && !authorized())
{
send({ status::unauthorized, request->version() },
std::bind(&channel_http::handle_unauthorized,
@@ -167,25 +167,27 @@ void channel_http::dispatch(const request_cptr& request) NOEXCEPT
return;
}
- // Electrum laxness (single value params) is never allowed here, btcd
- // laxness (batched v1) is allowed over ws (http upgrade) only.
+ // Electrum laxness (single value params) is allowed only where the
+ // service tolerates it, a v1 message within a batch (btcd) never is.
const auto& value = request->body();
if (value.contains())
{
const auto& body = value.get();
- if (body.lax_params)
+ if (body.lax_params && !lax_params())
{
stop(error::jsonrpc_params_not_collection);
return;
}
- if (!websocket() && body.lax_batch)
+ if (body.lax_batch)
{
stop(error::jsonrpc_batch_requires_v2);
return;
}
- // Batch is not supported over ws (btcd clients batch over http only).
+ // Batch is not supported over ws. Batching amortizes http request
+ // overhead, which ws does not incur, so pipelining obtains the same
+ // result without confining the set to a single frame.
if (websocket() && (body.batch || body.changed))
{
stop(error::jsonrpc_batch_unsupported);
@@ -222,7 +224,7 @@ flat_buffer& channel_http::request_buffer() NOEXCEPT
return request_buffer_;
}
-body::value_type channel_http::websocket_body() const NOEXCEPT
+body::value_type channel_http::default_body() const NOEXCEPT
{
// There is no forwarding constructor so assign and move.
body::value_type value{};
@@ -230,19 +232,26 @@ body::value_type channel_http::websocket_body() const NOEXCEPT
return value;
}
+bool channel_http::lax_params() const NOEXCEPT
+{
+ return false;
+}
+
// private
request_ptr channel_http::create_request() const NOEXCEPT
{
BC_ASSERT(stranded());
+ // The ws reader requires the body preselected, and a json-rpc body also
+ // implies detection. The http parse discards it (replaced by the parser).
const auto out = to_shared();
+ out->body() = default_body();
+
if (websocket())
{
// out->method() will return verb::unknown (mapped in dispatch).
- // socket will not produce verb::unknown for http requests (blocked).
- // plain_json value is not necessary since reader is explicitly set.
+ // socket will not produce verb::unknown for http requests (blocked).
out->method_string("websocket");
- out->body() = websocket_body();
}
return out;
@@ -269,7 +278,9 @@ void channel_http::notify(response&& notification,
result_handler&& handler) NOEXCEPT
{
BC_ASSERT(stranded());
- BC_ASSERT(websocket());
+
+ // A downgraded channel is full duplex, as is a websocket.
+ BC_ASSERT(websocket() || downgraded());
std::string message{ LOG_ONLY(log_message(notification)) };
@@ -300,8 +311,8 @@ void channel_http::assign_json_buffer(response& response) NOEXCEPT
{
BC_ASSERT(stranded());
- // websocket is full duplex, so cannot use shared json repsonse buffer.
- if (!websocket())
+ // Full duplex (ws/downgrade) cannot use the shared json response buffer.
+ if (!websocket() && !downgraded())
{
const auto& body = response.body();
if (body.contains())
diff --git a/src/messages/peer/body.cpp b/src/messages/peer/body.cpp
index 7a168c809..3f8faefcc 100644
--- a/src/messages/peer/body.cpp
+++ b/src/messages/peer/body.cpp
@@ -19,7 +19,7 @@
#include
#include
-#include
+#include
#include
#include
@@ -73,7 +73,7 @@ bool body::reader::accept(const std::span& payload,
return false;
}
- value_.payload = rpc::peer_registry::to_any(value_.head.index(), payload,
+ value_.payload = messages::peer::registry::to_any(value_.head.index(), payload,
value_.version, value_.witness);
if (!value_.payload)
@@ -137,7 +137,7 @@ size_t body::reader::put(const buffer_type& buffer, boost_code& ec) NOEXCEPT
void body::reader::put(uint8_t identifier, const std::string& command,
const std::span& payload, boost_code& ec) NOEXCEPT
{
- using registry = rpc::peer_registry;
+ using registry = messages::peer::registry;
ec = {};
const auto index = is_zero(identifier) ? registry::index(command) :
@@ -195,7 +195,7 @@ bool body::reader::done() const NOEXCEPT
void body::writer::init(boost_code& ec) NOEXCEPT
{
done_ = false;
- value_.data = rpc::peer_registry::to_frame(value_.index, value_.message,
+ value_.data = messages::peer::registry::to_frame(value_.index, value_.message,
value_.magic, value_.version);
ec = value_.data ? boost_code{} :
diff --git a/src/messages/peer/detail/heading.cpp b/src/messages/peer/detail/heading.cpp
index b8fb684c1..5d17f3389 100644
--- a/src/messages/peer/detail/heading.cpp
+++ b/src/messages/peer/detail/heading.cpp
@@ -19,7 +19,7 @@
#include
#include
-#include
+#include
#include
namespace libbitcoin {
@@ -125,7 +125,7 @@ void heading::serialize(writer& sink) const NOEXCEPT
size_t heading::index() const NOEXCEPT
{
- return rpc::peer_registry::index(command);
+ return messages::peer::registry::index(command);
}
} // namespace peer
diff --git a/src/net/proxy.cpp b/src/net/proxy.cpp
index 510e40edf..e7bcbe223 100644
--- a/src/net/proxy.cpp
+++ b/src/net/proxy.cpp
@@ -276,6 +276,16 @@ bool proxy::websocket() const NOEXCEPT
return socket_->websocket();
}
+bool proxy::downgraded() const NOEXCEPT
+{
+ return socket_->downgraded();
+}
+
+bool proxy::detected() const NOEXCEPT
+{
+ return socket_->detected();
+}
+
code proxy::accept_websocket(const http::request& request) NOEXCEPT
{
return socket_->accept_websocket(request);
diff --git a/src/net/proxy_actions.cpp b/src/net/proxy_actions.cpp
index 6b7722725..33801e12c 100644
--- a/src/net/proxy_actions.cpp
+++ b/src/net/proxy_actions.cpp
@@ -183,15 +183,25 @@ void proxy::read(http::flat_buffer& buffer, rpc::request& request,
{
BC_ASSERT(stranded());
do_reading();
+ do_rpc_request_read(std::ref(request), std::ref(buffer),
+ std::move(handler));
+}
+
+// private
+void proxy::do_rpc_request_read(const ref& request,
+ const ref& buffer,
+ const count_handler& handler) NOEXCEPT
+{
+ BC_ASSERT(stranded());
// Stamp current batch state (the parse is always lax).
- request.batch = batched_;
- request.changed = false;
+ auto& value = request.get();
+ value.batch = batched_;
+ value.changed = false;
- socket_->rpc_read(buffer, request,
+ socket_->rpc_read(buffer.get(), value,
std::bind(&proxy::handle_rpc_read,
- shared_from_this(), _1, _2, std::ref(request), std::ref(buffer),
- std::move(handler)));
+ shared_from_this(), _1, _2, request, buffer, handler));
}
// private
@@ -388,6 +398,26 @@ void proxy::read(http::flat_buffer& buffer, http::request& request,
return;
}
+ // A downgrade is the json-rpc transport, so it reads as one. The message
+ // lands in the body alternative of the caller's (channel's) request.
+ if (socket_->downgraded())
+ {
+ do_downgrade_read(std::ref(request), std::ref(buffer),
+ std::move(handler));
+ return;
+ }
+
+ // The preselected body is the read/write control, so a json-rpc body
+ // implies detection, performed before the first message is read.
+ if (!socket_->detected() && request.body().contains())
+ {
+ socket_->detect(buffer,
+ std::bind(&proxy::handle_detect,
+ shared_from_this(), _1, _2, std::ref(request),
+ std::ref(buffer), std::move(handler)));
+ return;
+ }
+
// Continue the message in progress (batched body), else next message.
if (parser_)
{
@@ -402,6 +432,47 @@ void proxy::read(http::flat_buffer& buffer, http::request& request,
std::move(handler));
}
+// private
+void proxy::handle_detect(const code& ec, size_t bytes,
+ const ref& request, const ref& buffer,
+ const count_handler& handler) NOEXCEPT
+{
+ BC_ASSERT(stranded());
+
+ if (ec)
+ {
+ handler(ec, bytes);
+ return;
+ }
+
+ if (socket_->downgraded())
+ {
+ do_downgrade_read(request, buffer, handler);
+ return;
+ }
+
+ do_http_request_read(request, buffer, handler);
+}
+
+// private
+void proxy::do_downgrade_read(const ref& request,
+ const ref& buffer,
+ const count_handler& handler) NOEXCEPT
+{
+ BC_ASSERT(stranded());
+
+ // A downgraded message carries no request line, so synthesize an unknown
+ // method for dispatch, as does the websocket upgrade.
+ auto& in = request.get();
+ in.method_string("stream");
+ if (!in.body().contains())
+ in.body() = rpc::request{};
+
+ // Read as json-rpc, which applies batch normalization.
+ do_rpc_request_read(std::ref(std::get(in.body().value())),
+ buffer, handler);
+}
+
// private
void proxy::do_http_request_read(const ref& request,
const ref& buffer,
@@ -537,6 +608,29 @@ void proxy::handle_http_close_write(const code& ec, size_t bytes,
void proxy::write(http::response&& response,
count_handler&& handler) NOEXCEPT
{
+ // A downgrade is the json-rpc transport, so it writes as one (batch
+ // stamping for a response, deferral while open for a notification).
+ if (socket_->downgraded())
+ {
+ auto& body = response.body();
+ if (body.contains())
+ {
+ write(std::move(std::get(body.value())),
+ std::move(handler));
+ return;
+ }
+
+ if (body.contains())
+ {
+ write(std::move(std::get(body.value())),
+ std::move(handler));
+ return;
+ }
+
+ handler(error::bad_stream, zero);
+ return;
+ }
+
if (socket_->websocket())
{
// Pointer ships moveable message through the send queue.
diff --git a/src/net/socket.cpp b/src/net/socket.cpp
index bf970858f..154aa7e63 100644
--- a/src/net/socket.cpp
+++ b/src/net/socket.cpp
@@ -117,6 +117,16 @@ bool socket::websocket() const NOEXCEPT
return websocket_.load();
}
+bool socket::downgraded() const NOEXCEPT
+{
+ return downgraded_.load();
+}
+
+bool socket::detected() const NOEXCEPT
+{
+ return detected_.load();
+}
+
const config::address& socket::address() const NOEXCEPT
{
return address_;
diff --git a/src/net/socket_http.cpp b/src/net/socket_http.cpp
index cf81c38ee..12e0c86a2 100644
--- a/src/net/socket_http.cpp
+++ b/src/net/socket_http.cpp
@@ -35,6 +35,91 @@ BC_PUSH_WARNING(NO_VALUE_OR_CONST_REF_SHARED_PTR)
BC_PUSH_WARNING(SMART_PTR_NOT_NEEDED)
BC_PUSH_WARNING(NO_THROW_IN_NOEXCEPT)
+// DETECT (first read).
+// ----------------------------------------------------------------------------
+
+// local
+constexpr bool is_json_open(char byte) NOEXCEPT
+{
+ // A json value opens with an object or array, and neither is a valid
+ // http method token character (rfc9110 tchar).
+ return byte == '{' || byte == '[';
+}
+
+// local
+constexpr bool is_line_break(char byte) NOEXCEPT
+{
+ // A server tolerates empty lines preceding a request line (rfc9112).
+ return byte == '\r' || byte == '\n';
+}
+
+// local
+// False implies inconclusive (the buffer holds only empty lines).
+inline bool detect_json(bool& json, const http::flat_buffer& buffer) NOEXCEPT
+{
+ const auto data = buffer.data();
+ const std::string_view bytes{ static_cast(data.data()),
+ data.size() };
+
+ for (const auto byte: bytes)
+ {
+ if (is_line_break(byte))
+ continue;
+
+ json = is_json_open(byte);
+ return true;
+ }
+
+ return false;
+}
+
+void socket::detect(http::flat_buffer& buffer,
+ count_handler&& handler) NOEXCEPT
+{
+ boost::asio::dispatch(strand_,
+ std::bind(&socket::do_detect, shared_from_this(),
+ std::ref(buffer), std::move(handler)));
+}
+
+// private
+void socket::do_detect(const ref& buffer,
+ const count_handler& handler) NOEXCEPT
+{
+ BC_ASSERT(stranded());
+
+ bool json{};
+ if (detect_json(json, buffer.get()))
+ {
+ detected_.store(true);
+ downgraded_.store(json);
+ handler(error::success, zero);
+ return;
+ }
+
+ // Tolerated empty lines only, so read more (bounded by the buffer).
+ async_read(buffer.get(),
+ std::bind(&socket::handle_detect,
+ shared_from_this(), _1, _2, buffer, handler));
+}
+
+// private
+void socket::handle_detect(const code& ec, size_t size,
+ const ref& buffer,
+ const count_handler& handler) NOEXCEPT
+{
+ BC_ASSERT(stranded());
+
+ if (ec)
+ {
+ handler(ec, size);
+ return;
+ }
+
+ // async_read prepares, the caller commits (as does handle_body_read).
+ buffer.get().commit(size);
+ do_detect(buffer, handler);
+}
+
// HTTP/WS (read).
// ----------------------------------------------------------------------------
@@ -52,6 +137,7 @@ void socket::do_http_read(ref buffer,
const count_handler& handler) NOEXCEPT
{
BC_ASSERT(stranded());
+
async_read_http(buffer.get(), request.get(), handler);
}
diff --git a/src/net/socket_peer.cpp b/src/net/socket_peer.cpp
index c4c193bcb..9f4842f83 100644
--- a/src/net/socket_peer.cpp
+++ b/src/net/socket_peer.cpp
@@ -19,7 +19,7 @@
#include
#include
-#include
+#include
#include
namespace libbitcoin {
@@ -155,7 +155,7 @@ void socket::do_peer_write(const frame_ptr& out,
if (encrypted())
{
- using registry = rpc::peer_registry;
+ using registry = messages::peer::registry;
const auto payload = registry::to_payload(out->index, out->message,
out->version);
diff --git a/src/net/socket_rpc.cpp b/src/net/socket_rpc.cpp
index ea26844d7..f9488bcc6 100644
--- a/src/net/socket_rpc.cpp
+++ b/src/net/socket_rpc.cpp
@@ -33,7 +33,7 @@ BC_PUSH_WARNING(NO_THROW_IN_NOEXCEPT)
// The transport is selected on the strand: a zmtp socket reads and writes
// the rpc message by its role (see socket_zmtp.cpp), otherwise the message
-// is a json-rpc body over tcp/ws.
+// is a json-rpc body over tcp.
void socket::rpc_read(http::flat_buffer& buffer, rpc::request& request,
count_handler&& handler) NOEXCEPT
@@ -103,7 +103,7 @@ void socket::do_rpc_write(const rpc::response_ptr& response,
return;
}
- // Stream (tcp/ws) messages are newline terminated (http chunks are not).
+ // Tcp stream messages are newline terminated (http/ws framed are not).
response->terminate = true;
http::response out{};
@@ -132,7 +132,7 @@ void socket::do_rpc_notify(const rpc::request_ptr& notification,
return;
}
- // Stream (tcp/ws) messages are newline terminated (http chunks are not).
+ // Tcp stream messages are newline terminated (http/ws framed are not).
notification->terminate = true;
http::request out{};
diff --git a/src/protocols/protocol_http.cpp b/src/protocols/protocol_http.cpp
index 7f32bf500..fb7c452b7 100644
--- a/src/protocols/protocol_http.cpp
+++ b/src/protocols/protocol_http.cpp
@@ -442,6 +442,11 @@ bool protocol_http::websocket() const NOEXCEPT
return channel_->websocket();
}
+bool protocol_http::downgraded() const NOEXCEPT
+{
+ return channel_->downgraded();
+}
+
bool protocol_http::permitted(const std::string& method) const NOEXCEPT
{
return channel_->permitted(method);
diff --git a/test/messages/peer/body.cpp b/test/messages/peer/body.cpp
index 9ed56a174..3af77b843 100644
--- a/test/messages/peer/body.cpp
+++ b/test/messages/peer/body.cpp
@@ -405,7 +405,7 @@ BOOST_AUTO_TEST_CASE(peer_body__writer__frame__emitted)
{
auto value = test_frame();
value.message = rpc::any_t{ system::to_shared(ping{ nonce }) };
- value.index = rpc::peer_registry::index_of();
+ value.index = messages::peer::registry::index_of();
boost_code ec{};
body::writer writer{ value };
@@ -427,7 +427,7 @@ BOOST_AUTO_TEST_CASE(peer_body__writer__get_twice__empty)
{
auto value = test_frame();
value.message = rpc::any_t{ system::to_shared(ping{ nonce }) };
- value.index = rpc::peer_registry::index_of();
+ value.index = messages::peer::registry::index_of();
boost_code ec{};
body::writer writer{ value };
diff --git a/test/messages/peer/detail/address.cpp b/test/messages/peer/detail/address.cpp
index b9e2932d3..bd2acb4c4 100644
--- a/test/messages/peer/detail/address.cpp
+++ b/test/messages/peer/detail/address.cpp
@@ -25,8 +25,8 @@ using namespace network::messages::peer;
BOOST_AUTO_TEST_CASE(address__properties__always__expected)
{
BOOST_REQUIRE_EQUAL(address::command, "addr");
- constexpr auto index = rpc::peer_registry::index_of();
- BOOST_REQUIRE_EQUAL(rpc::peer_registry::commands().at(index), address::command);
+ constexpr auto index = messages::peer::registry::index_of();
+ BOOST_REQUIRE_EQUAL(messages::peer::registry::commands().at(index), address::command);
BOOST_REQUIRE_EQUAL(address::version_minimum, level::minimum_protocol);
BOOST_REQUIRE_EQUAL(address::version_maximum, level::maximum_protocol);
}
diff --git a/test/messages/peer/detail/alert.cpp b/test/messages/peer/detail/alert.cpp
index 1308f6ce1..68db48fa6 100644
--- a/test/messages/peer/detail/alert.cpp
+++ b/test/messages/peer/detail/alert.cpp
@@ -27,8 +27,8 @@ using namespace network::messages::peer;
BOOST_AUTO_TEST_CASE(alert__properties__always__expected)
{
BOOST_REQUIRE_EQUAL(alert::command, "alert");
- constexpr auto index = rpc::peer_registry::index_of();
- BOOST_REQUIRE_EQUAL(rpc::peer_registry::commands().at(index), alert::command);
+ constexpr auto index = messages::peer::registry::index_of();
+ BOOST_REQUIRE_EQUAL(messages::peer::registry::commands().at(index), alert::command);
BOOST_REQUIRE_EQUAL(alert::version_minimum, level::minimum_protocol);
BOOST_REQUIRE_EQUAL(alert::version_maximum, level::maximum_protocol);
}
diff --git a/test/messages/peer/detail/block.cpp b/test/messages/peer/detail/block.cpp
index 6c3ef0319..9ca9079e8 100644
--- a/test/messages/peer/detail/block.cpp
+++ b/test/messages/peer/detail/block.cpp
@@ -25,8 +25,8 @@ using namespace network::messages;
BOOST_AUTO_TEST_CASE(block__properties__always__expected)
{
BOOST_REQUIRE_EQUAL(peer::block::command, "block");
- constexpr auto index = rpc::peer_registry::index_of();
- BOOST_REQUIRE_EQUAL(rpc::peer_registry::commands().at(index), peer::block::command);
+ constexpr auto index = messages::peer::registry::index_of();
+ BOOST_REQUIRE_EQUAL(messages::peer::registry::commands().at(index), peer::block::command);
BOOST_REQUIRE_EQUAL(peer::block::version_minimum, peer::level::minimum_protocol);
BOOST_REQUIRE_EQUAL(peer::block::version_maximum, peer::level::maximum_protocol);
}
diff --git a/test/messages/peer/detail/bloom_filter_add.cpp b/test/messages/peer/detail/bloom_filter_add.cpp
index a913398e2..425bdd542 100644
--- a/test/messages/peer/detail/bloom_filter_add.cpp
+++ b/test/messages/peer/detail/bloom_filter_add.cpp
@@ -25,8 +25,8 @@ using namespace network::messages::peer;
BOOST_AUTO_TEST_CASE(bloom_filter_add__properties__always__expected)
{
BOOST_REQUIRE_EQUAL(bloom_filter_add::command, "filteradd");
- constexpr auto index = rpc::peer_registry::index_of();
- BOOST_REQUIRE_EQUAL(rpc::peer_registry::commands().at(index), bloom_filter_add::command);
+ constexpr auto index = messages::peer::registry::index_of();
+ BOOST_REQUIRE_EQUAL(messages::peer::registry::commands().at(index), bloom_filter_add::command);
BOOST_REQUIRE_EQUAL(bloom_filter_add::version_minimum, level::bip37);
BOOST_REQUIRE_EQUAL(bloom_filter_add::version_maximum, level::maximum_protocol);
}
diff --git a/test/messages/peer/detail/bloom_filter_clear.cpp b/test/messages/peer/detail/bloom_filter_clear.cpp
index d94869b11..cf47745f4 100644
--- a/test/messages/peer/detail/bloom_filter_clear.cpp
+++ b/test/messages/peer/detail/bloom_filter_clear.cpp
@@ -25,8 +25,8 @@ using namespace network::messages::peer;
BOOST_AUTO_TEST_CASE(bloom_filter_clear__properties__always__expected)
{
BOOST_REQUIRE_EQUAL(bloom_filter_clear::command, "filterclear");
- constexpr auto index = rpc::peer_registry::index_of();
- BOOST_REQUIRE_EQUAL(rpc::peer_registry::commands().at(index), bloom_filter_clear::command);
+ constexpr auto index = messages::peer::registry::index_of();
+ BOOST_REQUIRE_EQUAL(messages::peer::registry::commands().at(index), bloom_filter_clear::command);
BOOST_REQUIRE_EQUAL(bloom_filter_clear::version_minimum, level::bip37);
BOOST_REQUIRE_EQUAL(bloom_filter_clear::version_maximum, level::maximum_protocol);
}
diff --git a/test/messages/peer/detail/bloom_filter_load.cpp b/test/messages/peer/detail/bloom_filter_load.cpp
index 6b41a2614..ba13617a2 100644
--- a/test/messages/peer/detail/bloom_filter_load.cpp
+++ b/test/messages/peer/detail/bloom_filter_load.cpp
@@ -25,8 +25,8 @@ using namespace network::messages::peer;
BOOST_AUTO_TEST_CASE(bloom_filter_load__properties__always__expected)
{
BOOST_REQUIRE_EQUAL(bloom_filter_load::command, "filterload");
- constexpr auto index = rpc::peer_registry::index_of();
- BOOST_REQUIRE_EQUAL(rpc::peer_registry::commands().at(index), bloom_filter_load::command);
+ constexpr auto index = messages::peer::registry::index_of();
+ BOOST_REQUIRE_EQUAL(messages::peer::registry::commands().at(index), bloom_filter_load::command);
BOOST_REQUIRE_EQUAL(bloom_filter_load::version_minimum, level::bip37);
BOOST_REQUIRE_EQUAL(bloom_filter_load::version_maximum, level::maximum_protocol);
}
diff --git a/test/messages/peer/detail/client_filter.cpp b/test/messages/peer/detail/client_filter.cpp
index 90a67f24e..144535402 100644
--- a/test/messages/peer/detail/client_filter.cpp
+++ b/test/messages/peer/detail/client_filter.cpp
@@ -25,8 +25,8 @@ using namespace network::messages::peer;
BOOST_AUTO_TEST_CASE(client_filter__properties__always__expected)
{
BOOST_REQUIRE_EQUAL(client_filter::command, "cfilter");
- constexpr auto index = rpc::peer_registry::index_of();
- BOOST_REQUIRE_EQUAL(rpc::peer_registry::commands().at(index), client_filter::command);
+ constexpr auto index = messages::peer::registry::index_of();
+ BOOST_REQUIRE_EQUAL(messages::peer::registry::commands().at(index), client_filter::command);
BOOST_REQUIRE_EQUAL(client_filter::version_minimum, level::bip157);
BOOST_REQUIRE_EQUAL(client_filter::version_maximum, level::maximum_protocol);
}
diff --git a/test/messages/peer/detail/client_filter_checkpoint.cpp b/test/messages/peer/detail/client_filter_checkpoint.cpp
index 730837f42..729d1b752 100644
--- a/test/messages/peer/detail/client_filter_checkpoint.cpp
+++ b/test/messages/peer/detail/client_filter_checkpoint.cpp
@@ -25,8 +25,8 @@ using namespace network::messages::peer;
BOOST_AUTO_TEST_CASE(client_filter_checkpoint__properties__always__expected)
{
BOOST_REQUIRE_EQUAL(client_filter_checkpoint::command, "cfcheckpt");
- constexpr auto index = rpc::peer_registry::index_of();
- BOOST_REQUIRE_EQUAL(rpc::peer_registry::commands().at(index), client_filter_checkpoint::command);
+ constexpr auto index = messages::peer::registry::index_of();
+ BOOST_REQUIRE_EQUAL(messages::peer::registry::commands().at(index), client_filter_checkpoint::command);
BOOST_REQUIRE_EQUAL(client_filter_checkpoint::version_minimum, level::bip157);
BOOST_REQUIRE_EQUAL(client_filter_checkpoint::version_maximum, level::maximum_protocol);
}
diff --git a/test/messages/peer/detail/client_filter_headers.cpp b/test/messages/peer/detail/client_filter_headers.cpp
index 63e36ae3e..d7fddbbc1 100644
--- a/test/messages/peer/detail/client_filter_headers.cpp
+++ b/test/messages/peer/detail/client_filter_headers.cpp
@@ -25,8 +25,8 @@ using namespace network::messages::peer;
BOOST_AUTO_TEST_CASE(client_filter_headers__properties__always__expected)
{
BOOST_REQUIRE_EQUAL(client_filter_headers::command, "cfheaders");
- constexpr auto index = rpc::peer_registry::index_of();
- BOOST_REQUIRE_EQUAL(rpc::peer_registry::commands().at(index), client_filter_headers::command);
+ constexpr auto index = messages::peer::registry::index_of();
+ BOOST_REQUIRE_EQUAL(messages::peer::registry::commands().at(index), client_filter_headers::command);
BOOST_REQUIRE_EQUAL(client_filter_headers::version_minimum, level::bip157);
BOOST_REQUIRE_EQUAL(client_filter_headers::version_maximum, level::maximum_protocol);
}
diff --git a/test/messages/peer/detail/compact_block.cpp b/test/messages/peer/detail/compact_block.cpp
index 16628489b..7c4edf11f 100644
--- a/test/messages/peer/detail/compact_block.cpp
+++ b/test/messages/peer/detail/compact_block.cpp
@@ -25,8 +25,8 @@ using namespace network::messages::peer;
BOOST_AUTO_TEST_CASE(compact_block__properties__always__expected)
{
BOOST_REQUIRE_EQUAL(compact_block::command, "cmpctblock");
- constexpr auto index = rpc::peer_registry::index_of();
- BOOST_REQUIRE_EQUAL(rpc::peer_registry::commands().at(index), compact_block::command);
+ constexpr auto index = messages::peer::registry::index_of();
+ BOOST_REQUIRE_EQUAL(messages::peer::registry::commands().at(index), compact_block::command);
BOOST_REQUIRE_EQUAL(compact_block::version_minimum, level::bip152);
BOOST_REQUIRE_EQUAL(compact_block::version_maximum, level::maximum_protocol);
}
diff --git a/test/messages/peer/detail/compact_transactions.cpp b/test/messages/peer/detail/compact_transactions.cpp
index 56d99c6c9..ff71f0e4c 100644
--- a/test/messages/peer/detail/compact_transactions.cpp
+++ b/test/messages/peer/detail/compact_transactions.cpp
@@ -25,8 +25,8 @@ using namespace network::messages::peer;
BOOST_AUTO_TEST_CASE(ccompact_transactions__properties__always__expected)
{
BOOST_REQUIRE_EQUAL(compact_transactions::command, "blocktxn");
- constexpr auto index = rpc::peer_registry::index_of();
- BOOST_REQUIRE_EQUAL(rpc::peer_registry::commands().at(index), compact_transactions::command);
+ constexpr auto index = messages::peer::registry::index_of();
+ BOOST_REQUIRE_EQUAL(messages::peer::registry::commands().at(index), compact_transactions::command);
BOOST_REQUIRE_EQUAL(compact_transactions::version_minimum, level::bip152);
BOOST_REQUIRE_EQUAL(compact_transactions::version_maximum, level::maximum_protocol);
}
diff --git a/test/messages/peer/detail/fee_filter.cpp b/test/messages/peer/detail/fee_filter.cpp
index 01b537e4d..a4cd08cf8 100644
--- a/test/messages/peer/detail/fee_filter.cpp
+++ b/test/messages/peer/detail/fee_filter.cpp
@@ -25,8 +25,8 @@ using namespace network::messages::peer;
BOOST_AUTO_TEST_CASE(fee_filter__properties__always__expected)
{
BOOST_REQUIRE_EQUAL(fee_filter::command, "feefilter");
- constexpr auto index = rpc::peer_registry::index_of();
- BOOST_REQUIRE_EQUAL(rpc::peer_registry::commands().at(index), fee_filter::command);
+ constexpr auto index = messages::peer::registry::index_of();
+ BOOST_REQUIRE_EQUAL(messages::peer::registry::commands().at(index), fee_filter::command);
BOOST_REQUIRE_EQUAL(fee_filter::version_minimum, level::bip133);
BOOST_REQUIRE_EQUAL(fee_filter::version_maximum, level::maximum_protocol);
}
diff --git a/test/messages/peer/detail/get_address.cpp b/test/messages/peer/detail/get_address.cpp
index cb14c7688..f366c5cab 100644
--- a/test/messages/peer/detail/get_address.cpp
+++ b/test/messages/peer/detail/get_address.cpp
@@ -25,8 +25,8 @@ using namespace network::messages::peer;
BOOST_AUTO_TEST_CASE(get_address__properties__always__expected)
{
BOOST_REQUIRE_EQUAL(get_address::command, "getaddr");
- constexpr auto index = rpc::peer_registry::index_of();
- BOOST_REQUIRE_EQUAL(rpc::peer_registry::commands().at(index), get_address::command);
+ constexpr auto index = messages::peer::registry::index_of();
+ BOOST_REQUIRE_EQUAL(messages::peer::registry::commands().at(index), get_address::command);
BOOST_REQUIRE_EQUAL(get_address::version_minimum, level::minimum_protocol);
BOOST_REQUIRE_EQUAL(get_address::version_maximum, level::maximum_protocol);
}
diff --git a/test/messages/peer/detail/get_blocks.cpp b/test/messages/peer/detail/get_blocks.cpp
index 69deafeab..2e4e3daba 100644
--- a/test/messages/peer/detail/get_blocks.cpp
+++ b/test/messages/peer/detail/get_blocks.cpp
@@ -25,8 +25,8 @@ using namespace network::messages::peer;
BOOST_AUTO_TEST_CASE(get_blocks__properties__always__expected)
{
BOOST_REQUIRE_EQUAL(get_blocks::command, "getblocks");
- constexpr auto index = rpc::peer_registry::index_of();
- BOOST_REQUIRE_EQUAL(rpc::peer_registry::commands().at(index), get_blocks::command);
+ constexpr auto index = messages::peer::registry::index_of();
+ BOOST_REQUIRE_EQUAL(messages::peer::registry::commands().at(index), get_blocks::command);
BOOST_REQUIRE_EQUAL(get_blocks::version_minimum, level::minimum_protocol);
BOOST_REQUIRE_EQUAL(get_blocks::version_maximum, level::maximum_protocol);
}
diff --git a/test/messages/peer/detail/get_client_filter_checkpoint.cpp b/test/messages/peer/detail/get_client_filter_checkpoint.cpp
index 06fc89fcf..f8424bb55 100644
--- a/test/messages/peer/detail/get_client_filter_checkpoint.cpp
+++ b/test/messages/peer/detail/get_client_filter_checkpoint.cpp
@@ -25,8 +25,8 @@ using namespace network::messages::peer;
BOOST_AUTO_TEST_CASE(get_client_filter_checkpoint__properties__always__expected)
{
BOOST_REQUIRE_EQUAL(get_client_filter_checkpoint::command, "getcfcheckpt");
- constexpr auto index = rpc::peer_registry::index_of();
- BOOST_REQUIRE_EQUAL(rpc::peer_registry::commands().at(index), get_client_filter_checkpoint::command);
+ constexpr auto index = messages::peer::registry::index_of();
+ BOOST_REQUIRE_EQUAL(messages::peer::registry::commands().at(index), get_client_filter_checkpoint::command);
BOOST_REQUIRE_EQUAL(get_client_filter_checkpoint::version_minimum, level::bip157);
BOOST_REQUIRE_EQUAL(get_client_filter_checkpoint::version_maximum, level::maximum_protocol);
}
diff --git a/test/messages/peer/detail/get_client_filter_headers.cpp b/test/messages/peer/detail/get_client_filter_headers.cpp
index d0ad04527..0721a28a8 100644
--- a/test/messages/peer/detail/get_client_filter_headers.cpp
+++ b/test/messages/peer/detail/get_client_filter_headers.cpp
@@ -25,8 +25,8 @@ using namespace network::messages::peer;
BOOST_AUTO_TEST_CASE(get_client_filter_headers__properties__always__expected)
{
BOOST_REQUIRE_EQUAL(get_client_filter_headers::command, "getcfheaders");
- constexpr auto index = rpc::peer_registry::index_of();
- BOOST_REQUIRE_EQUAL(rpc::peer_registry::commands().at(index), get_client_filter_headers::command);
+ constexpr auto index = messages::peer::registry::index_of();
+ BOOST_REQUIRE_EQUAL(messages::peer::registry::commands().at(index), get_client_filter_headers::command);
BOOST_REQUIRE_EQUAL(get_client_filter_headers::version_minimum, level::bip157);
BOOST_REQUIRE_EQUAL(get_client_filter_headers::version_maximum, level::maximum_protocol);
}
diff --git a/test/messages/peer/detail/get_client_filters.cpp b/test/messages/peer/detail/get_client_filters.cpp
index ab8545e4e..0919fa5de 100644
--- a/test/messages/peer/detail/get_client_filters.cpp
+++ b/test/messages/peer/detail/get_client_filters.cpp
@@ -25,8 +25,8 @@ using namespace network::messages::peer;
BOOST_AUTO_TEST_CASE(get_client_filters__properties__always__expected)
{
BOOST_REQUIRE_EQUAL(get_client_filters::command, "getcfilters");
- constexpr auto index = rpc::peer_registry::index_of();
- BOOST_REQUIRE_EQUAL(rpc::peer_registry::commands().at(index), get_client_filters::command);
+ constexpr auto index = messages::peer::registry::index_of();
+ BOOST_REQUIRE_EQUAL(messages::peer::registry::commands().at(index), get_client_filters::command);
BOOST_REQUIRE_EQUAL(get_client_filters::version_minimum, level::bip157);
BOOST_REQUIRE_EQUAL(get_client_filters::version_maximum, level::maximum_protocol);
}
diff --git a/test/messages/peer/detail/get_compact_transactions.cpp b/test/messages/peer/detail/get_compact_transactions.cpp
index d53f38aa5..83ffae44d 100644
--- a/test/messages/peer/detail/get_compact_transactions.cpp
+++ b/test/messages/peer/detail/get_compact_transactions.cpp
@@ -25,8 +25,8 @@ using namespace network::messages::peer;
BOOST_AUTO_TEST_CASE(get_compact_transactions__properties__always__expected)
{
BOOST_REQUIRE_EQUAL(get_compact_transactions::command, "getblocktxn");
- constexpr auto index = rpc::peer_registry::index_of();
- BOOST_REQUIRE_EQUAL(rpc::peer_registry::commands().at(index), get_compact_transactions::command);
+ constexpr auto index = messages::peer::registry::index_of();
+ BOOST_REQUIRE_EQUAL(messages::peer::registry::commands().at(index), get_compact_transactions::command);
BOOST_REQUIRE_EQUAL(get_compact_transactions::version_minimum, level::bip152);
BOOST_REQUIRE_EQUAL(get_compact_transactions::version_maximum, level::maximum_protocol);
}
diff --git a/test/messages/peer/detail/get_data.cpp b/test/messages/peer/detail/get_data.cpp
index 0bb650b23..6b6c1e67e 100644
--- a/test/messages/peer/detail/get_data.cpp
+++ b/test/messages/peer/detail/get_data.cpp
@@ -53,8 +53,8 @@ static get_data make_mixed_inventory() NOEXCEPT
BOOST_AUTO_TEST_CASE(get_data__properties__always__expected)
{
BOOST_REQUIRE_EQUAL(get_data::command, "getdata");
- constexpr auto index = rpc::peer_registry::index_of();
- BOOST_REQUIRE_EQUAL(rpc::peer_registry::commands().at(index), get_data::command);
+ constexpr auto index = messages::peer::registry::index_of();
+ BOOST_REQUIRE_EQUAL(messages::peer::registry::commands().at(index), get_data::command);
BOOST_REQUIRE_EQUAL(get_data::version_minimum, level::minimum_protocol);
BOOST_REQUIRE_EQUAL(get_data::version_maximum, level::maximum_protocol);
}
diff --git a/test/messages/peer/detail/get_headers.cpp b/test/messages/peer/detail/get_headers.cpp
index cf710d9ba..0d3ed1c61 100644
--- a/test/messages/peer/detail/get_headers.cpp
+++ b/test/messages/peer/detail/get_headers.cpp
@@ -25,8 +25,8 @@ using namespace network::messages::peer;
BOOST_AUTO_TEST_CASE(get_headers__properties__always__expected)
{
BOOST_REQUIRE_EQUAL(get_headers::command, "getheaders");
- constexpr auto index = rpc::peer_registry::index_of();
- BOOST_REQUIRE_EQUAL(rpc::peer_registry::commands().at(index), get_headers::command);
+ constexpr auto index = messages::peer::registry::index_of();
+ BOOST_REQUIRE_EQUAL(messages::peer::registry::commands().at(index), get_headers::command);
BOOST_REQUIRE_EQUAL(get_headers::version_minimum, level::headers_protocol);
BOOST_REQUIRE_EQUAL(get_headers::version_maximum, level::maximum_protocol);
}
diff --git a/test/messages/peer/detail/headers.cpp b/test/messages/peer/detail/headers.cpp
index a6a53a5a6..8b96b549f 100644
--- a/test/messages/peer/detail/headers.cpp
+++ b/test/messages/peer/detail/headers.cpp
@@ -26,8 +26,8 @@ using namespace network::messages::peer;
BOOST_AUTO_TEST_CASE(headers__properties__always__expected)
{
BOOST_REQUIRE_EQUAL(headers::command, "headers");
- constexpr auto index = rpc::peer_registry::index_of();
- BOOST_REQUIRE_EQUAL(rpc::peer_registry::commands().at(index), headers::command);
+ constexpr auto index = messages::peer::registry::index_of();
+ BOOST_REQUIRE_EQUAL(messages::peer::registry::commands().at(index), headers::command);
BOOST_REQUIRE_EQUAL(headers::version_minimum, level::headers_protocol);
BOOST_REQUIRE_EQUAL(headers::version_maximum, level::maximum_protocol);
}
diff --git a/test/messages/peer/detail/inventory.cpp b/test/messages/peer/detail/inventory.cpp
index e1a4b9326..1c7f3d773 100644
--- a/test/messages/peer/detail/inventory.cpp
+++ b/test/messages/peer/detail/inventory.cpp
@@ -53,8 +53,8 @@ static inventory make_mixed_inventory() NOEXCEPT
BOOST_AUTO_TEST_CASE(inventory__properties__always__expected)
{
BOOST_REQUIRE_EQUAL(inventory::command, "inv");
- constexpr auto index = rpc::peer_registry::index_of();
- BOOST_REQUIRE_EQUAL(rpc::peer_registry::commands().at(index), inventory::command);
+ constexpr auto index = messages::peer::registry::index_of();
+ BOOST_REQUIRE_EQUAL(messages::peer::registry::commands().at(index), inventory::command);
BOOST_REQUIRE_EQUAL(inventory::version_minimum, level::minimum_protocol);
BOOST_REQUIRE_EQUAL(inventory::version_maximum, level::maximum_protocol);
}
diff --git a/test/messages/peer/detail/memory_pool.cpp b/test/messages/peer/detail/memory_pool.cpp
index 7911082e9..a4df46cc5 100644
--- a/test/messages/peer/detail/memory_pool.cpp
+++ b/test/messages/peer/detail/memory_pool.cpp
@@ -25,8 +25,8 @@ using namespace network::messages::peer;
BOOST_AUTO_TEST_CASE(memory_pool__properties__always__expected)
{
BOOST_REQUIRE_EQUAL(memory_pool::command, "mempool");
- constexpr auto index = rpc::peer_registry::index_of();
- BOOST_REQUIRE_EQUAL(rpc::peer_registry::commands().at(index), memory_pool::command);
+ constexpr auto index = messages::peer::registry::index_of();
+ BOOST_REQUIRE_EQUAL(messages::peer::registry::commands().at(index), memory_pool::command);
BOOST_REQUIRE_EQUAL(memory_pool::version_minimum, level::bip35);
BOOST_REQUIRE_EQUAL(memory_pool::version_maximum, level::maximum_protocol);
}
diff --git a/test/messages/peer/detail/merkle_block.cpp b/test/messages/peer/detail/merkle_block.cpp
index e163cd3b2..9a22bf137 100644
--- a/test/messages/peer/detail/merkle_block.cpp
+++ b/test/messages/peer/detail/merkle_block.cpp
@@ -26,8 +26,8 @@ using namespace network::messages::peer;
BOOST_AUTO_TEST_CASE(merkle_block__properties__always__expected)
{
BOOST_REQUIRE_EQUAL(merkle_block::command, "merkleblock");
- constexpr auto index = rpc::peer_registry::index_of();
- BOOST_REQUIRE_EQUAL(rpc::peer_registry::commands().at(index), merkle_block::command);
+ constexpr auto index = messages::peer::registry::index_of();
+ BOOST_REQUIRE_EQUAL(messages::peer::registry::commands().at(index), merkle_block::command);
BOOST_REQUIRE_EQUAL(merkle_block::version_minimum, level::bip37);
BOOST_REQUIRE_EQUAL(merkle_block::version_maximum, level::maximum_protocol);
}
diff --git a/test/messages/peer/detail/not_found.cpp b/test/messages/peer/detail/not_found.cpp
index 7e74a792a..ae7701da4 100644
--- a/test/messages/peer/detail/not_found.cpp
+++ b/test/messages/peer/detail/not_found.cpp
@@ -25,8 +25,8 @@ using namespace network::messages::peer;
BOOST_AUTO_TEST_CASE(not_found__properties__always__expected)
{
BOOST_REQUIRE_EQUAL(not_found::command, "notfound");
- constexpr auto index = rpc::peer_registry::index_of();
- BOOST_REQUIRE_EQUAL(rpc::peer_registry::commands().at(index), not_found::command);
+ constexpr auto index = messages::peer::registry::index_of();
+ BOOST_REQUIRE_EQUAL(messages::peer::registry::commands().at(index), not_found::command);
BOOST_REQUIRE_EQUAL(not_found::version_minimum, level::bip37);
BOOST_REQUIRE_EQUAL(not_found::version_maximum, level::maximum_protocol);
}
diff --git a/test/messages/peer/detail/ping.cpp b/test/messages/peer/detail/ping.cpp
index 7c9c2c2e6..b76831f71 100644
--- a/test/messages/peer/detail/ping.cpp
+++ b/test/messages/peer/detail/ping.cpp
@@ -25,8 +25,8 @@ using namespace network::messages::peer;
BOOST_AUTO_TEST_CASE(ping__properties__always__expected)
{
BOOST_REQUIRE_EQUAL(ping::command, "ping");
- constexpr auto index = rpc::peer_registry::index_of();
- BOOST_REQUIRE_EQUAL(rpc::peer_registry::commands().at(index), ping::command);
+ constexpr auto index = messages::peer::registry::index_of();
+ BOOST_REQUIRE_EQUAL(messages::peer::registry::commands().at(index), ping::command);
BOOST_REQUIRE_EQUAL(ping::version_minimum, level::minimum_protocol);
BOOST_REQUIRE_EQUAL(ping::version_maximum, level::maximum_protocol);
}
diff --git a/test/messages/peer/detail/pong.cpp b/test/messages/peer/detail/pong.cpp
index 0d4bbb23b..e8ae7497b 100644
--- a/test/messages/peer/detail/pong.cpp
+++ b/test/messages/peer/detail/pong.cpp
@@ -25,8 +25,8 @@ using namespace network::messages::peer;
BOOST_AUTO_TEST_CASE(pong__properties__always__expected)
{
BOOST_REQUIRE_EQUAL(pong::command, "pong");
- constexpr auto index = rpc::peer_registry::index_of();
- BOOST_REQUIRE_EQUAL(rpc::peer_registry::commands().at(index), pong::command);
+ constexpr auto index = messages::peer::registry::index_of();
+ BOOST_REQUIRE_EQUAL(messages::peer::registry::commands().at(index), pong::command);
BOOST_REQUIRE_EQUAL(pong::version_minimum, level::bip31);
BOOST_REQUIRE_EQUAL(pong::version_maximum, level::maximum_protocol);
}
diff --git a/test/messages/peer/detail/reject.cpp b/test/messages/peer/detail/reject.cpp
index b64032968..846ad9527 100644
--- a/test/messages/peer/detail/reject.cpp
+++ b/test/messages/peer/detail/reject.cpp
@@ -25,8 +25,8 @@ using namespace network::messages::peer;
BOOST_AUTO_TEST_CASE(reject__properties__always__expected)
{
BOOST_REQUIRE_EQUAL(reject::command, "reject");
- constexpr auto index = rpc::peer_registry::index_of();
- BOOST_REQUIRE_EQUAL(rpc::peer_registry::commands().at(index), reject::command);
+ constexpr auto index = messages::peer::registry::index_of();
+ BOOST_REQUIRE_EQUAL(messages::peer::registry::commands().at(index), reject::command);
BOOST_REQUIRE_EQUAL(reject::version_minimum, level::bip61);
BOOST_REQUIRE_EQUAL(reject::version_maximum, level::maximum_protocol);
}
diff --git a/test/messages/peer/detail/send_address_v2.cpp b/test/messages/peer/detail/send_address_v2.cpp
index 43d7811a6..5c9391727 100644
--- a/test/messages/peer/detail/send_address_v2.cpp
+++ b/test/messages/peer/detail/send_address_v2.cpp
@@ -25,8 +25,8 @@ using namespace network::messages::peer;
BOOST_AUTO_TEST_CASE(send_address_v2__properties__always__expected)
{
BOOST_REQUIRE_EQUAL(send_address_v2::command, "sendaddrv2");
- constexpr auto index = rpc::peer_registry::index_of();
- BOOST_REQUIRE_EQUAL(rpc::peer_registry::commands().at(index), send_address_v2::command);
+ constexpr auto index = messages::peer::registry::index_of();
+ BOOST_REQUIRE_EQUAL(messages::peer::registry::commands().at(index), send_address_v2::command);
BOOST_REQUIRE_EQUAL(send_address_v2::version_minimum, level::bip155);
BOOST_REQUIRE_EQUAL(send_address_v2::version_maximum, level::maximum_protocol);
}
diff --git a/test/messages/peer/detail/send_compact.cpp b/test/messages/peer/detail/send_compact.cpp
index a9c2988e0..636b059b5 100644
--- a/test/messages/peer/detail/send_compact.cpp
+++ b/test/messages/peer/detail/send_compact.cpp
@@ -25,8 +25,8 @@ using namespace network::messages::peer;
BOOST_AUTO_TEST_CASE(send_compact__properties__always__expected)
{
BOOST_REQUIRE_EQUAL(send_compact::command, "sendcmpct");
- constexpr auto index = rpc::peer_registry::index_of();
- BOOST_REQUIRE_EQUAL(rpc::peer_registry::commands().at(index), send_compact::command);
+ constexpr auto index = messages::peer::registry::index_of();
+ BOOST_REQUIRE_EQUAL(messages::peer::registry::commands().at(index), send_compact::command);
BOOST_REQUIRE_EQUAL(send_compact::version_minimum, level::bip152);
BOOST_REQUIRE_EQUAL(send_compact::version_maximum, level::maximum_protocol);
}
diff --git a/test/messages/peer/detail/send_headers.cpp b/test/messages/peer/detail/send_headers.cpp
index 3dd128c44..ec50a36c9 100644
--- a/test/messages/peer/detail/send_headers.cpp
+++ b/test/messages/peer/detail/send_headers.cpp
@@ -25,8 +25,8 @@ using namespace network::messages::peer;
BOOST_AUTO_TEST_CASE(send_headers__properties__always__expected)
{
BOOST_REQUIRE_EQUAL(send_headers::command, "sendheaders");
- constexpr auto index = rpc::peer_registry::index_of();
- BOOST_REQUIRE_EQUAL(rpc::peer_registry::commands().at(index), send_headers::command);
+ constexpr auto index = messages::peer::registry::index_of();
+ BOOST_REQUIRE_EQUAL(messages::peer::registry::commands().at(index), send_headers::command);
BOOST_REQUIRE_EQUAL(send_headers::version_minimum, level::bip130);
BOOST_REQUIRE_EQUAL(send_headers::version_maximum, level::maximum_protocol);
}
diff --git a/test/messages/peer/detail/transaction.cpp b/test/messages/peer/detail/transaction.cpp
index fe2dc15c5..077cdbddb 100644
--- a/test/messages/peer/detail/transaction.cpp
+++ b/test/messages/peer/detail/transaction.cpp
@@ -25,8 +25,8 @@ using namespace network::messages::peer;
BOOST_AUTO_TEST_CASE(transaction__properties__always__expected)
{
BOOST_REQUIRE_EQUAL(transaction::command, "tx");
- constexpr auto index = rpc::peer_registry::index_of();
- BOOST_REQUIRE_EQUAL(rpc::peer_registry::commands().at(index), transaction::command);
+ constexpr auto index = messages::peer::registry::index_of();
+ BOOST_REQUIRE_EQUAL(messages::peer::registry::commands().at(index), transaction::command);
BOOST_REQUIRE_EQUAL(transaction::version_minimum, level::minimum_protocol);
BOOST_REQUIRE_EQUAL(transaction::version_maximum, level::maximum_protocol);
}
diff --git a/test/messages/peer/detail/version.cpp b/test/messages/peer/detail/version.cpp
index e4fc58b14..726dfbd33 100644
--- a/test/messages/peer/detail/version.cpp
+++ b/test/messages/peer/detail/version.cpp
@@ -26,8 +26,8 @@ using namespace network::messages::peer;
BOOST_AUTO_TEST_CASE(version__properties__always__expected)
{
BOOST_REQUIRE_EQUAL(version::command, "version");
- constexpr auto index = rpc::peer_registry::index_of();
- BOOST_REQUIRE_EQUAL(rpc::peer_registry::commands().at(index), version::command);
+ constexpr auto index = messages::peer::registry::index_of();
+ BOOST_REQUIRE_EQUAL(messages::peer::registry::commands().at(index), version::command);
BOOST_REQUIRE_EQUAL(version::version_minimum, level::minimum_protocol);
BOOST_REQUIRE_EQUAL(version::version_maximum, level::maximum_protocol);
}
diff --git a/test/messages/peer/detail/version_acknowledge.cpp b/test/messages/peer/detail/version_acknowledge.cpp
index 687d01d9a..1c935d16e 100644
--- a/test/messages/peer/detail/version_acknowledge.cpp
+++ b/test/messages/peer/detail/version_acknowledge.cpp
@@ -25,8 +25,8 @@ using namespace network::messages::peer;
BOOST_AUTO_TEST_CASE(version_acknowledge__properties__always__expected)
{
BOOST_REQUIRE_EQUAL(version_acknowledge::command, "verack");
- constexpr auto index = rpc::peer_registry::index_of();
- BOOST_REQUIRE_EQUAL(rpc::peer_registry::commands().at(index), version_acknowledge::command);
+ constexpr auto index = messages::peer::registry::index_of();
+ BOOST_REQUIRE_EQUAL(messages::peer::registry::commands().at(index), version_acknowledge::command);
BOOST_REQUIRE_EQUAL(version_acknowledge::version_minimum, level::minimum_protocol);
BOOST_REQUIRE_EQUAL(version_acknowledge::version_maximum, level::maximum_protocol);
}
diff --git a/test/messages/peer/detail/witness_tx_id_relay.cpp b/test/messages/peer/detail/witness_tx_id_relay.cpp
index 1c1602776..9b2077db2 100644
--- a/test/messages/peer/detail/witness_tx_id_relay.cpp
+++ b/test/messages/peer/detail/witness_tx_id_relay.cpp
@@ -25,8 +25,8 @@ using namespace network::messages::peer;
BOOST_AUTO_TEST_CASE(witness_tx_id_relay__properties__always__expected)
{
BOOST_REQUIRE_EQUAL(witness_tx_id_relay::command, "wtxidrelay");
- constexpr auto index = rpc::peer_registry::index_of();
- BOOST_REQUIRE_EQUAL(rpc::peer_registry::commands().at(index), witness_tx_id_relay::command);
+ constexpr auto index = messages::peer::registry::index_of();
+ BOOST_REQUIRE_EQUAL(messages::peer::registry::commands().at(index), witness_tx_id_relay::command);
BOOST_REQUIRE_EQUAL(witness_tx_id_relay::version_minimum, level::bip339);
BOOST_REQUIRE_EQUAL(witness_tx_id_relay::version_maximum, level::maximum_protocol);
}
diff --git a/test/messages/peer/heading.cpp b/test/messages/peer/heading.cpp
index 60b0ee0f9..52f757ff1 100644
--- a/test/messages/peer/heading.cpp
+++ b/test/messages/peer/heading.cpp
@@ -45,9 +45,9 @@ BOOST_AUTO_TEST_CASE(rpc_heading__size__always__expected)
BOOST_AUTO_TEST_CASE(rpc_heading__index__registered_commands__own_index)
{
- for (size_t expected{}; expected < rpc::peer_registry::size; ++expected)
+ for (size_t expected{}; expected < messages::peer::registry::size; ++expected)
{
- const std::string command{ rpc::peer_registry::commands().at(expected) };
+ const std::string command{ messages::peer::registry::commands().at(expected) };
const auto instance = heading{ 0u, command, 0u, 0u };
BOOST_REQUIRE_EQUAL(instance.index(), expected);
}
@@ -56,13 +56,13 @@ BOOST_AUTO_TEST_CASE(rpc_heading__index__registered_commands__own_index)
BOOST_AUTO_TEST_CASE(rpc_heading__index__unregistered_command__unknown)
{
const auto instance = heading{ 0u, "bogus", 0u, 0u };
- BOOST_REQUIRE_EQUAL(instance.index(), rpc::peer_registry::unknown);
+ BOOST_REQUIRE_EQUAL(instance.index(), messages::peer::registry::unknown);
}
BOOST_AUTO_TEST_CASE(rpc_heading__index__empty_command__unknown)
{
const auto instance = heading{ 0u, "", 0u, 0u };
- BOOST_REQUIRE_EQUAL(instance.index(), rpc::peer_registry::unknown);
+ BOOST_REQUIRE_EQUAL(instance.index(), messages::peer::registry::unknown);
}
BOOST_AUTO_TEST_CASE(rpc_heading__get_command__empty_payload__unknown)
@@ -110,7 +110,7 @@ BOOST_AUTO_TEST_CASE(rpc_heading__factory1__empty__expected)
BOOST_REQUIRE_EQUAL(instance.magic, magic);
BOOST_REQUIRE_EQUAL(instance.command, command);
BOOST_REQUIRE_EQUAL(instance.checksum, empty_checksum);
- BOOST_REQUIRE_EQUAL(instance.index(), rpc::peer_registry::index("ping"));
+ BOOST_REQUIRE_EQUAL(instance.index(), messages::peer::registry::index("ping"));
}
BOOST_AUTO_TEST_CASE(rpc_heading__factory2__default_hash__expected)
@@ -123,7 +123,7 @@ BOOST_AUTO_TEST_CASE(rpc_heading__factory2__default_hash__expected)
BOOST_REQUIRE_EQUAL(instance.magic, magic);
BOOST_REQUIRE_EQUAL(instance.command, command);
BOOST_REQUIRE_EQUAL(instance.checksum, empty_checksum);
- BOOST_REQUIRE_EQUAL(instance.index(), rpc::peer_registry::index("pong"));
+ BOOST_REQUIRE_EQUAL(instance.index(), messages::peer::registry::index("pong"));
}
BOOST_AUTO_TEST_CASE(rpc_heading__factory2__empty_hash__expected)
@@ -136,7 +136,7 @@ BOOST_AUTO_TEST_CASE(rpc_heading__factory2__empty_hash__expected)
BOOST_REQUIRE_EQUAL(instance.magic, magic);
BOOST_REQUIRE_EQUAL(instance.command, command);
BOOST_REQUIRE_EQUAL(instance.checksum, empty_checksum);
- BOOST_REQUIRE_EQUAL(instance.index(), rpc::peer_registry::index("pong"));
+ BOOST_REQUIRE_EQUAL(instance.index(), messages::peer::registry::index("pong"));
}
BOOST_AUTO_TEST_SUITE_END()