From 392f26d5e5fc81f5571749fdd72297040eb424a0 Mon Sep 17 00:00:00 2001 From: evoskuil Date: Fri, 26 Dec 2025 18:18:43 -0500 Subject: [PATCH] Reorganized rpc and messages. --- Makefile.am | 73 +++++----- builds/cmake/CMakeLists.txt | 24 ++-- .../libbitcoin-network-test.vcxproj | 22 +-- .../libbitcoin-network-test.vcxproj.filters | 60 ++++---- .../libbitcoin-network.vcxproj | 37 ++--- .../libbitcoin-network.vcxproj.filters | 135 +++++++++--------- include/bitcoin/network.hpp | 27 ++-- .../bitcoin/network/channels/channel_http.hpp | 1 - .../bitcoin/network/channels/channel_peer.hpp | 1 - include/bitcoin/network/define.hpp | 7 +- .../impl/{ => messages}/rpc/broadcaster.ipp | 8 +- .../impl/{ => messages}/rpc/dispatcher.ipp | 10 +- include/bitcoin/network/interface/http.hpp | 2 +- .../network/interface/peer_broadcast.hpp | 2 +- .../network/interface/peer_dispatch.hpp | 2 +- .../{rpc/rpc.hpp => messages/http/http.hpp} | 19 ++- .../{monad_body.hpp => http_body.hpp} | 62 +++----- .../{http/method.hpp => http_method.hpp} | 3 +- include/bitcoin/network/messages/messages.hpp | 15 +- .../network/{ => messages}/rpc/any.hpp | 4 +- .../messages/{rpc_body.hpp => rpc/body.hpp} | 9 ++ .../{ => messages}/rpc/broadcaster.hpp | 8 +- .../network/{ => messages}/rpc/dispatcher.hpp | 10 +- .../{ => messages}/rpc/enums/grouping.hpp | 4 +- .../{ => messages}/rpc/enums/version.hpp | 4 +- .../network/{ => messages}/rpc/method.hpp | 6 +- .../network/{ => messages}/rpc/model.hpp | 8 +- .../network/{ => messages}/rpc/publish.hpp | 8 +- include/bitcoin/network/messages/rpc/rpc.hpp | 33 +++++ .../network/{ => messages}/rpc/types.hpp | 6 +- include/bitcoin/network/net.hpp | 1 - include/bitcoin/network/net/proxy.hpp | 8 +- include/bitcoin/network/net/socket.hpp | 23 ++- include/bitcoin/network/sessions/session.hpp | 1 - src/channels/channel_http.cpp | 9 +- .../{monad_body.cpp => http_body.cpp} | 11 +- src/messages/{rpc_body.cpp => rpc/body.cpp} | 4 +- src/{ => messages}/rpc/model.cpp | 4 +- src/net/proxy.cpp | 5 +- src/net/socket.cpp | 7 +- src/settings.cpp | 1 - ...d_body_reader.cpp => http_body_reader.cpp} | 16 +-- ...d_body_writer.cpp => http_body_writer.cpp} | 20 +-- test/{ => messages}/rpc/any.cpp | 2 +- .../body_reader.cpp} | 2 +- .../body_writer.cpp} | 2 +- test/{ => messages}/rpc/broadcaster.cpp | 2 +- test/{ => messages}/rpc/dispatcher.cpp | 2 +- test/{ => messages}/rpc/method.cpp | 2 +- test/{ => messages}/rpc/types.cpp | 2 +- 50 files changed, 368 insertions(+), 366 deletions(-) rename include/bitcoin/network/impl/{ => messages}/rpc/broadcaster.ipp (95%) rename include/bitcoin/network/impl/{ => messages}/rpc/dispatcher.ipp (97%) rename include/bitcoin/network/{rpc/rpc.hpp => messages/http/http.hpp} (62%) rename include/bitcoin/network/messages/{monad_body.hpp => http_body.hpp} (87%) rename include/bitcoin/network/messages/{http/method.hpp => http_method.hpp} (94%) rename include/bitcoin/network/{ => messages}/rpc/any.hpp (97%) rename include/bitcoin/network/messages/{rpc_body.hpp => rpc/body.hpp} (89%) rename include/bitcoin/network/{ => messages}/rpc/broadcaster.hpp (94%) rename include/bitcoin/network/{ => messages}/rpc/dispatcher.hpp (95%) rename include/bitcoin/network/{ => messages}/rpc/enums/grouping.hpp (91%) rename include/bitcoin/network/{ => messages}/rpc/enums/version.hpp (91%) rename include/bitcoin/network/{ => messages}/rpc/method.hpp (97%) rename include/bitcoin/network/{ => messages}/rpc/model.hpp (96%) rename include/bitcoin/network/{ => messages}/rpc/publish.hpp (87%) create mode 100644 include/bitcoin/network/messages/rpc/rpc.hpp rename include/bitcoin/network/{ => messages}/rpc/types.hpp (98%) rename src/messages/{monad_body.cpp => http_body.cpp} (95%) rename src/messages/{rpc_body.cpp => rpc/body.cpp} (98%) rename src/{ => messages}/rpc/model.cpp (98%) rename test/messages/{monad_body_reader.cpp => http_body_reader.cpp} (82%) rename test/messages/{monad_body_writer.cpp => http_body_writer.cpp} (81%) rename test/{ => messages}/rpc/any.cpp (99%) rename test/messages/{rpc_body_reader.cpp => rpc/body_reader.cpp} (99%) rename test/messages/{rpc_body_writer.cpp => rpc/body_writer.cpp} (99%) rename test/{ => messages}/rpc/broadcaster.cpp (99%) rename test/{ => messages}/rpc/dispatcher.cpp (99%) rename test/{ => messages}/rpc/method.cpp (99%) rename test/{ => messages}/rpc/types.cpp (99%) diff --git a/Makefile.am b/Makefile.am index 7f21cd408..65ba76e1b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -54,8 +54,7 @@ src_libbitcoin_network_la_SOURCES = \ src/log/capture.cpp \ src/log/logger.cpp \ src/log/reporter.cpp \ - src/messages/monad_body.cpp \ - src/messages/rpc_body.cpp \ + src/messages/http_body.cpp \ src/messages/http/fields.cpp \ src/messages/http/enums/media_type.cpp \ src/messages/http/enums/target.cpp \ @@ -100,6 +99,8 @@ src_libbitcoin_network_la_SOURCES = \ src/messages/peer/detail/version.cpp \ src/messages/peer/detail/version_acknowledge.cpp \ src/messages/peer/detail/witness_tx_id_relay.cpp \ + src/messages/rpc/body.cpp \ + src/messages/rpc/model.cpp \ src/net/acceptor.cpp \ src/net/connector.cpp \ src/net/deadline.cpp \ @@ -120,7 +121,6 @@ src_libbitcoin_network_la_SOURCES = \ src/protocols/protocol_version_70001.cpp \ src/protocols/protocol_version_70002.cpp \ src/protocols/protocol_version_70016.cpp \ - src/rpc/model.cpp \ src/sessions/session.cpp \ src/sessions/session_inbound.cpp \ src/sessions/session_manual.cpp \ @@ -169,12 +169,10 @@ test_libbitcoin_network_test_SOURCES = \ test/config/utilities.cpp \ test/log/timer.cpp \ test/log/tracker.cpp \ + test/messages/http_body_reader.cpp \ + test/messages/http_body_writer.cpp \ test/messages/json_body_reader.cpp \ test/messages/json_body_writer.cpp \ - test/messages/monad_body_reader.cpp \ - test/messages/monad_body_writer.cpp \ - test/messages/rpc_body_reader.cpp \ - test/messages/rpc_body_writer.cpp \ test/messages/http/fields.cpp \ test/messages/http/method.cpp \ test/messages/http/enums/magic_numbers.cpp \ @@ -225,6 +223,13 @@ test_libbitcoin_network_test_SOURCES = \ test/messages/peer/enums/level.cpp \ test/messages/peer/enums/magic_numbers.cpp \ test/messages/peer/enums/service.cpp \ + test/messages/rpc/any.cpp \ + test/messages/rpc/body_reader.cpp \ + test/messages/rpc/body_writer.cpp \ + test/messages/rpc/broadcaster.cpp \ + test/messages/rpc/dispatcher.cpp \ + test/messages/rpc/method.cpp \ + test/messages/rpc/types.cpp \ test/net/acceptor.cpp \ test/net/connector.cpp \ test/net/deadline.cpp \ @@ -245,11 +250,6 @@ test_libbitcoin_network_test_SOURCES = \ test/protocols/protocol_version_70001.cpp \ test/protocols/protocol_version_70002.cpp \ test/protocols/protocol_version_70016.cpp \ - test/rpc/any.cpp \ - test/rpc/broadcaster.cpp \ - test/rpc/dispatcher.cpp \ - test/rpc/method.cpp \ - test/rpc/types.cpp \ test/sessions/session.cpp \ test/sessions/session_html.cpp \ test/sessions/session_inbound.cpp \ @@ -335,10 +335,10 @@ include_bitcoin_network_impl_messagesdir = ${includedir}/bitcoin/network/impl/me include_bitcoin_network_impl_messages_HEADERS = \ include/bitcoin/network/impl/messages/json_body.ipp -include_bitcoin_network_impl_rpcdir = ${includedir}/bitcoin/network/impl/rpc -include_bitcoin_network_impl_rpc_HEADERS = \ - include/bitcoin/network/impl/rpc/broadcaster.ipp \ - include/bitcoin/network/impl/rpc/dispatcher.ipp +include_bitcoin_network_impl_messages_rpcdir = ${includedir}/bitcoin/network/impl/messages/rpc +include_bitcoin_network_impl_messages_rpc_HEADERS = \ + include/bitcoin/network/impl/messages/rpc/broadcaster.ipp \ + include/bitcoin/network/impl/messages/rpc/dispatcher.ipp include_bitcoin_network_interfacedir = ${includedir}/bitcoin/network/interface include_bitcoin_network_interface_HEADERS = \ @@ -359,15 +359,15 @@ include_bitcoin_network_log_HEADERS = \ include_bitcoin_network_messagesdir = ${includedir}/bitcoin/network/messages include_bitcoin_network_messages_HEADERS = \ + include/bitcoin/network/messages/http_body.hpp \ + include/bitcoin/network/messages/http_method.hpp \ include/bitcoin/network/messages/json_body.hpp \ - include/bitcoin/network/messages/messages.hpp \ - include/bitcoin/network/messages/monad_body.hpp \ - include/bitcoin/network/messages/rpc_body.hpp + include/bitcoin/network/messages/messages.hpp include_bitcoin_network_messages_httpdir = ${includedir}/bitcoin/network/messages/http include_bitcoin_network_messages_http_HEADERS = \ include/bitcoin/network/messages/http/fields.hpp \ - include/bitcoin/network/messages/http/method.hpp + include/bitcoin/network/messages/http/http.hpp include_bitcoin_network_messages_http_enumsdir = ${includedir}/bitcoin/network/messages/http/enums include_bitcoin_network_messages_http_enums_HEADERS = \ @@ -432,6 +432,23 @@ include_bitcoin_network_messages_peer_enums_HEADERS = \ include/bitcoin/network/messages/peer/enums/magic_numbers.hpp \ include/bitcoin/network/messages/peer/enums/service.hpp +include_bitcoin_network_messages_rpcdir = ${includedir}/bitcoin/network/messages/rpc +include_bitcoin_network_messages_rpc_HEADERS = \ + include/bitcoin/network/messages/rpc/any.hpp \ + include/bitcoin/network/messages/rpc/body.hpp \ + include/bitcoin/network/messages/rpc/broadcaster.hpp \ + include/bitcoin/network/messages/rpc/dispatcher.hpp \ + include/bitcoin/network/messages/rpc/method.hpp \ + include/bitcoin/network/messages/rpc/model.hpp \ + include/bitcoin/network/messages/rpc/publish.hpp \ + include/bitcoin/network/messages/rpc/rpc.hpp \ + include/bitcoin/network/messages/rpc/types.hpp + +include_bitcoin_network_messages_rpc_enumsdir = ${includedir}/bitcoin/network/messages/rpc/enums +include_bitcoin_network_messages_rpc_enums_HEADERS = \ + include/bitcoin/network/messages/rpc/enums/grouping.hpp \ + include/bitcoin/network/messages/rpc/enums/version.hpp + include_bitcoin_network_netdir = ${includedir}/bitcoin/network/net include_bitcoin_network_net_HEADERS = \ include/bitcoin/network/net/acceptor.hpp \ @@ -462,22 +479,6 @@ include_bitcoin_network_protocols_HEADERS = \ include/bitcoin/network/protocols/protocol_ws.hpp \ include/bitcoin/network/protocols/protocols.hpp -include_bitcoin_network_rpcdir = ${includedir}/bitcoin/network/rpc -include_bitcoin_network_rpc_HEADERS = \ - include/bitcoin/network/rpc/any.hpp \ - include/bitcoin/network/rpc/broadcaster.hpp \ - include/bitcoin/network/rpc/dispatcher.hpp \ - include/bitcoin/network/rpc/method.hpp \ - include/bitcoin/network/rpc/model.hpp \ - include/bitcoin/network/rpc/publish.hpp \ - include/bitcoin/network/rpc/rpc.hpp \ - include/bitcoin/network/rpc/types.hpp - -include_bitcoin_network_rpc_enumsdir = ${includedir}/bitcoin/network/rpc/enums -include_bitcoin_network_rpc_enums_HEADERS = \ - include/bitcoin/network/rpc/enums/grouping.hpp \ - include/bitcoin/network/rpc/enums/version.hpp - include_bitcoin_network_sessionsdir = ${includedir}/bitcoin/network/sessions include_bitcoin_network_sessions_HEADERS = \ include/bitcoin/network/sessions/session.hpp \ diff --git a/builds/cmake/CMakeLists.txt b/builds/cmake/CMakeLists.txt index f1f4f93f7..a8a499b45 100644 --- a/builds/cmake/CMakeLists.txt +++ b/builds/cmake/CMakeLists.txt @@ -236,8 +236,7 @@ add_library( ${CANONICAL_LIB_NAME} "../../src/log/capture.cpp" "../../src/log/logger.cpp" "../../src/log/reporter.cpp" - "../../src/messages/monad_body.cpp" - "../../src/messages/rpc_body.cpp" + "../../src/messages/http_body.cpp" "../../src/messages/http/fields.cpp" "../../src/messages/http/enums/media_type.cpp" "../../src/messages/http/enums/target.cpp" @@ -282,6 +281,8 @@ add_library( ${CANONICAL_LIB_NAME} "../../src/messages/peer/detail/version.cpp" "../../src/messages/peer/detail/version_acknowledge.cpp" "../../src/messages/peer/detail/witness_tx_id_relay.cpp" + "../../src/messages/rpc/body.cpp" + "../../src/messages/rpc/model.cpp" "../../src/net/acceptor.cpp" "../../src/net/connector.cpp" "../../src/net/deadline.cpp" @@ -302,7 +303,6 @@ add_library( ${CANONICAL_LIB_NAME} "../../src/protocols/protocol_version_70001.cpp" "../../src/protocols/protocol_version_70002.cpp" "../../src/protocols/protocol_version_70016.cpp" - "../../src/rpc/model.cpp" "../../src/sessions/session.cpp" "../../src/sessions/session_inbound.cpp" "../../src/sessions/session_manual.cpp" @@ -375,12 +375,10 @@ if (with-tests) "../../test/config/utilities.cpp" "../../test/log/timer.cpp" "../../test/log/tracker.cpp" + "../../test/messages/http_body_reader.cpp" + "../../test/messages/http_body_writer.cpp" "../../test/messages/json_body_reader.cpp" "../../test/messages/json_body_writer.cpp" - "../../test/messages/monad_body_reader.cpp" - "../../test/messages/monad_body_writer.cpp" - "../../test/messages/rpc_body_reader.cpp" - "../../test/messages/rpc_body_writer.cpp" "../../test/messages/http/fields.cpp" "../../test/messages/http/method.cpp" "../../test/messages/http/enums/magic_numbers.cpp" @@ -431,6 +429,13 @@ if (with-tests) "../../test/messages/peer/enums/level.cpp" "../../test/messages/peer/enums/magic_numbers.cpp" "../../test/messages/peer/enums/service.cpp" + "../../test/messages/rpc/any.cpp" + "../../test/messages/rpc/body_reader.cpp" + "../../test/messages/rpc/body_writer.cpp" + "../../test/messages/rpc/broadcaster.cpp" + "../../test/messages/rpc/dispatcher.cpp" + "../../test/messages/rpc/method.cpp" + "../../test/messages/rpc/types.cpp" "../../test/net/acceptor.cpp" "../../test/net/connector.cpp" "../../test/net/deadline.cpp" @@ -451,11 +456,6 @@ if (with-tests) "../../test/protocols/protocol_version_70001.cpp" "../../test/protocols/protocol_version_70002.cpp" "../../test/protocols/protocol_version_70016.cpp" - "../../test/rpc/any.cpp" - "../../test/rpc/broadcaster.cpp" - "../../test/rpc/dispatcher.cpp" - "../../test/rpc/method.cpp" - "../../test/rpc/types.cpp" "../../test/sessions/session.cpp" "../../test/sessions/session_html.cpp" "../../test/sessions/session_inbound.cpp" diff --git a/builds/msvc/vs2022/libbitcoin-network-test/libbitcoin-network-test.vcxproj b/builds/msvc/vs2022/libbitcoin-network-test/libbitcoin-network-test.vcxproj index dbf25e770..d35cce7f1 100644 --- a/builds/msvc/vs2022/libbitcoin-network-test/libbitcoin-network-test.vcxproj +++ b/builds/msvc/vs2022/libbitcoin-network-test/libbitcoin-network-test.vcxproj @@ -155,10 +155,10 @@ $(IntDir)test_messages_http_method.obj + + - - $(IntDir)test_messages_peer_detail_address.obj @@ -208,8 +208,15 @@ - - + + + + + + + $(IntDir)test_messages_rpc_method.obj + + @@ -231,13 +238,6 @@ - - - - - $(IntDir)test_rpc_method.obj - - diff --git a/builds/msvc/vs2022/libbitcoin-network-test/libbitcoin-network-test.vcxproj.filters b/builds/msvc/vs2022/libbitcoin-network-test/libbitcoin-network-test.vcxproj.filters index 2a5db43f3..9abeb9195 100644 --- a/builds/msvc/vs2022/libbitcoin-network-test/libbitcoin-network-test.vcxproj.filters +++ b/builds/msvc/vs2022/libbitcoin-network-test/libbitcoin-network-test.vcxproj.filters @@ -14,7 +14,7 @@ {D28FC18A-8B81-4247-0000-000000000001} - {D28FC18A-8B81-4247-0000-00000000000A} + {D28FC18A-8B81-4247-0000-000000000009} {D28FC18A-8B81-4247-0000-000000000002} @@ -29,13 +29,13 @@ {D28FC18A-8B81-4247-0000-000000000005} - {D28FC18A-8B81-4247-0000-00000000000B} + {D28FC18A-8B81-4247-0000-00000000000A} {D28FC18A-8B81-4247-0000-00000000000D} - {D28FC18A-8B81-4247-0000-00000000000C} + {D28FC18A-8B81-4247-0000-00000000000B} {D28FC18A-8B81-4247-0000-00000000000E} @@ -43,17 +43,17 @@ {D28FC18A-8B81-4247-0000-00000000000F} + + {D28FC18A-8B81-4247-0000-00000000000C} + {D28FC18A-8B81-4247-0000-000000000006} {D28FC18A-8B81-4247-0000-000000000007} - - {D28FC18A-8B81-4247-0000-000000000008} - - {D28FC18A-8B81-4247-0000-000000000009} + {D28FC18A-8B81-4247-0000-000000000008} @@ -150,16 +150,16 @@ src\messages\http - + src\messages - + src\messages - + src\messages - + src\messages @@ -297,11 +297,26 @@ src\messages\peer - - src\messages + + src\messages\rpc - - src\messages + + src\messages\rpc + + + src\messages\rpc + + + src\messages\rpc + + + src\messages\rpc + + + src\messages\rpc + + + src\messages\rpc src @@ -366,21 +381,6 @@ src\protocols - - src\rpc - - - src\rpc - - - src\rpc - - - src\rpc - - - src\rpc - src\sessions diff --git a/builds/msvc/vs2022/libbitcoin-network/libbitcoin-network.vcxproj b/builds/msvc/vs2022/libbitcoin-network/libbitcoin-network.vcxproj index 56fbe5986..9740d1580 100644 --- a/builds/msvc/vs2022/libbitcoin-network/libbitcoin-network.vcxproj +++ b/builds/msvc/vs2022/libbitcoin-network/libbitcoin-network.vcxproj @@ -143,7 +143,7 @@ - + $(IntDir)src_messages_peer_detail_address.obj @@ -187,7 +187,8 @@ - + + @@ -209,7 +210,6 @@ - @@ -270,10 +270,11 @@ - + + + - @@ -320,7 +321,17 @@ - + + + + + + + + + + + @@ -346,16 +357,6 @@ - - - - - - - - - - @@ -378,8 +379,8 @@ - - + + diff --git a/builds/msvc/vs2022/libbitcoin-network/libbitcoin-network.vcxproj.filters b/builds/msvc/vs2022/libbitcoin-network/libbitcoin-network.vcxproj.filters index c43582d76..9e9a46971 100644 --- a/builds/msvc/vs2022/libbitcoin-network/libbitcoin-network.vcxproj.filters +++ b/builds/msvc/vs2022/libbitcoin-network/libbitcoin-network.vcxproj.filters @@ -20,7 +20,7 @@ {564EB540-D6B6-425C-0000-000000000002} - {564EB540-D6B6-425C-0000-0000000000C1} + {564EB540-D6B6-425C-0000-0000000000B1} {564EB540-D6B6-425C-0000-000000000003} @@ -32,15 +32,15 @@ {564EB540-D6B6-425C-0000-000000000005} - {564EB540-D6B6-425C-0000-0000000000D1} + {564EB540-D6B6-425C-0000-0000000000C1} - {564EB540-D6B6-425C-0000-000000000002} + {564EB540-D6B6-425C-0000-0000000000E1} - {564EB540-D6B6-425C-0000-0000000000E1} + {564EB540-D6B6-425C-0000-0000000000D1} - + {564EB540-D6B6-425C-0000-0000000000F1} @@ -53,13 +53,13 @@ {564EB540-D6B6-425C-0000-000000000008} - {564EB540-D6B6-425C-0000-000000000003} + {564EB540-D6B6-425C-0000-000000000002} {564EB540-D6B6-425C-0000-000000000005} - {564EB540-D6B6-425C-0000-000000000004} + {564EB540-D6B6-425C-0000-000000000003} {564EB540-D6B6-425C-0000-000000000006} @@ -67,20 +67,20 @@ {564EB540-D6B6-425C-0000-000000000007} + + {564EB540-D6B6-425C-0000-000000000004} + + + {564EB540-D6B6-425C-0000-000000000008} + {564EB540-D6B6-425C-0000-000000000009} {564EB540-D6B6-425C-0000-000000000010} - - {564EB540-D6B6-425C-0000-0000000000A1} - - - {564EB540-D6B6-425C-0000-000000000008} - - {564EB540-D6B6-425C-0000-0000000000B1} + {564EB540-D6B6-425C-0000-0000000000A1} {564EB540-D6B6-425C-0000-000000000009} @@ -104,28 +104,28 @@ {564EB540-D6B6-425C-0000-000000000005} - {564EB540-D6B6-425C-0000-00000000000A} + {564EB540-D6B6-425C-0000-000000000009} {564EB540-D6B6-425C-0000-00000000000C} - {564EB540-D6B6-425C-0000-00000000000B} + {564EB540-D6B6-425C-0000-00000000000A} {564EB540-D6B6-425C-0000-00000000000D} + + {564EB540-D6B6-425C-0000-00000000000B} + {564EB540-D6B6-425C-0000-000000000006} {564EB540-D6B6-425C-0000-000000000007} - - {564EB540-D6B6-425C-0000-000000000008} - - {564EB540-D6B6-425C-0000-000000000009} + {564EB540-D6B6-425C-0000-000000000008} @@ -189,7 +189,7 @@ src\messages\http - + src\messages @@ -315,8 +315,11 @@ src\messages\peer - - src\messages + + src\messages\rpc + + + src\messages\rpc src @@ -381,9 +384,6 @@ src\protocols - - src\rpc - src\sessions @@ -560,16 +560,19 @@ include\bitcoin\network\messages\http - + include\bitcoin\network\messages\http - + include\bitcoin\network\messages - + + include\bitcoin\network\messages + + include\bitcoin\network\messages - + include\bitcoin\network\messages @@ -710,8 +713,38 @@ include\bitcoin\network\messages\peer - - include\bitcoin\network\messages + + include\bitcoin\network\messages\rpc + + + include\bitcoin\network\messages\rpc + + + include\bitcoin\network\messages\rpc + + + include\bitcoin\network\messages\rpc + + + include\bitcoin\network\messages\rpc\enums + + + include\bitcoin\network\messages\rpc\enums + + + include\bitcoin\network\messages\rpc + + + include\bitcoin\network\messages\rpc + + + include\bitcoin\network\messages\rpc + + + include\bitcoin\network\messages\rpc + + + include\bitcoin\network\messages\rpc include\bitcoin\network @@ -788,36 +821,6 @@ include\bitcoin\network\protocols - - include\bitcoin\network\rpc - - - include\bitcoin\network\rpc - - - include\bitcoin\network\rpc - - - include\bitcoin\network\rpc\enums - - - include\bitcoin\network\rpc\enums - - - include\bitcoin\network\rpc - - - include\bitcoin\network\rpc - - - include\bitcoin\network\rpc - - - include\bitcoin\network\rpc - - - include\bitcoin\network\rpc - include\bitcoin\network\sessions @@ -880,11 +883,11 @@ include\bitcoin\network\impl\messages - - include\bitcoin\network\impl\rpc + + include\bitcoin\network\impl\messages\rpc - - include\bitcoin\network\impl\rpc + + include\bitcoin\network\impl\messages\rpc diff --git a/include/bitcoin/network.hpp b/include/bitcoin/network.hpp index f6c7a15aa..cfc6da2eb 100644 --- a/include/bitcoin/network.hpp +++ b/include/bitcoin/network.hpp @@ -61,12 +61,12 @@ #include #include #include +#include +#include #include #include -#include -#include #include -#include +#include #include #include #include @@ -118,6 +118,17 @@ #include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include @@ -142,16 +153,6 @@ #include #include #include -#include -#include -#include -#include -#include -#include -#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 103ab3846..17db27f58 100644 --- a/include/bitcoin/network/channels/channel_http.hpp +++ b/include/bitcoin/network/channels/channel_http.hpp @@ -27,7 +27,6 @@ #include #include #include -#include #include namespace libbitcoin { diff --git a/include/bitcoin/network/channels/channel_peer.hpp b/include/bitcoin/network/channels/channel_peer.hpp index 421b8448e..98f8b7eec 100644 --- a/include/bitcoin/network/channels/channel_peer.hpp +++ b/include/bitcoin/network/channels/channel_peer.hpp @@ -26,7 +26,6 @@ #include #include #include -#include namespace libbitcoin { namespace network { diff --git a/include/bitcoin/network/define.hpp b/include/bitcoin/network/define.hpp index 7a23e3116..730f79c31 100644 --- a/include/bitcoin/network/define.hpp +++ b/include/bitcoin/network/define.hpp @@ -155,11 +155,10 @@ namespace network { // /async : define // /log : define /async -// /messages : define memory -// /config : define /messages /async +// /messages : define memory /async +// /config : define /messages +// /interface : define /messages // /net : define settings memory /config /log -// /rpc : define /messages /async -// /interface : define /rpc // /channels : define /net /interface // /sessions : define /channels // /protocols : define /sessions diff --git a/include/bitcoin/network/impl/rpc/broadcaster.ipp b/include/bitcoin/network/impl/messages/rpc/broadcaster.ipp similarity index 95% rename from include/bitcoin/network/impl/rpc/broadcaster.ipp rename to include/bitcoin/network/impl/messages/rpc/broadcaster.ipp index 42d78794c..74c4c5cc3 100644 --- a/include/bitcoin/network/impl/rpc/broadcaster.ipp +++ b/include/bitcoin/network/impl/messages/rpc/broadcaster.ipp @@ -16,15 +16,15 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -#ifndef LIBBITCOIN_NETWORK_RPC_BROADCASTER_IPP -#define LIBBITCOIN_NETWORK_RPC_BROADCASTER_IPP +#ifndef LIBBITCOIN_NETWORK_MESSAGES_RPC_BROADCASTER_IPP +#define LIBBITCOIN_NETWORK_MESSAGES_RPC_BROADCASTER_IPP #include #include #include #include -#include -#include +#include +#include namespace libbitcoin { namespace network { diff --git a/include/bitcoin/network/impl/rpc/dispatcher.ipp b/include/bitcoin/network/impl/messages/rpc/dispatcher.ipp similarity index 97% rename from include/bitcoin/network/impl/rpc/dispatcher.ipp rename to include/bitcoin/network/impl/messages/rpc/dispatcher.ipp index 3ef5e5133..276917bb7 100644 --- a/include/bitcoin/network/impl/rpc/dispatcher.ipp +++ b/include/bitcoin/network/impl/messages/rpc/dispatcher.ipp @@ -16,8 +16,8 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -#ifndef LIBBITCOIN_NETWORK_RPC_DISPATCHER_IPP -#define LIBBITCOIN_NETWORK_RPC_DISPATCHER_IPP +#ifndef LIBBITCOIN_NETWORK_MESSAGES_RPC_DISPATCHER_IPP +#define LIBBITCOIN_NETWORK_MESSAGES_RPC_DISPATCHER_IPP #include #include @@ -25,9 +25,9 @@ #include #include #include -#include -#include -#include +#include +#include +#include namespace libbitcoin { namespace network { diff --git a/include/bitcoin/network/interface/http.hpp b/include/bitcoin/network/interface/http.hpp index 03092b8a5..b99eec924 100644 --- a/include/bitcoin/network/interface/http.hpp +++ b/include/bitcoin/network/interface/http.hpp @@ -22,7 +22,7 @@ #include #include #include -#include +#include namespace libbitcoin { namespace network { diff --git a/include/bitcoin/network/interface/peer_broadcast.hpp b/include/bitcoin/network/interface/peer_broadcast.hpp index 4957ab1b8..b243dce96 100644 --- a/include/bitcoin/network/interface/peer_broadcast.hpp +++ b/include/bitcoin/network/interface/peer_broadcast.hpp @@ -22,7 +22,7 @@ #include #include #include -#include +#include namespace libbitcoin { namespace network { diff --git a/include/bitcoin/network/interface/peer_dispatch.hpp b/include/bitcoin/network/interface/peer_dispatch.hpp index c90ab64e8..7d6020c8f 100644 --- a/include/bitcoin/network/interface/peer_dispatch.hpp +++ b/include/bitcoin/network/interface/peer_dispatch.hpp @@ -22,7 +22,7 @@ #include #include #include -#include +#include namespace libbitcoin { namespace network { diff --git a/include/bitcoin/network/rpc/rpc.hpp b/include/bitcoin/network/messages/http/http.hpp similarity index 62% rename from include/bitcoin/network/rpc/rpc.hpp rename to include/bitcoin/network/messages/http/http.hpp index 0383a3a4c..4d56feae3 100644 --- a/include/bitcoin/network/rpc/rpc.hpp +++ b/include/bitcoin/network/messages/http/http.hpp @@ -16,17 +16,14 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -#ifndef LIBBITCOIN_NETWORK_RPC_RPC_HPP -#define LIBBITCOIN_NETWORK_RPC_RPC_HPP +#ifndef LIBBITCOIN_NETWORK_MESSAGES_HTTP_HTTP_HPP +#define LIBBITCOIN_NETWORK_MESSAGES_HTTP_HTTP_HPP -#include -#include -#include -#include -#include -#include -#include -#include -#include + #include + #include + #include + #include + #include + #include #endif diff --git a/include/bitcoin/network/messages/monad_body.hpp b/include/bitcoin/network/messages/http_body.hpp similarity index 87% rename from include/bitcoin/network/messages/monad_body.hpp rename to include/bitcoin/network/messages/http_body.hpp index 6534571f9..2274d66ea 100644 --- a/include/bitcoin/network/messages/monad_body.hpp +++ b/include/bitcoin/network/messages/http_body.hpp @@ -16,35 +16,20 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -#ifndef LIBBITCOIN_NETWORK_MESSAGES_MONAD_BODY_HPP -#define LIBBITCOIN_NETWORK_MESSAGES_MONAD_BODY_HPP +#ifndef LIBBITCOIN_NETWORK_MESSAGES_HTTP_BODY_HPP +#define LIBBITCOIN_NETWORK_MESSAGES_HTTP_BODY_HPP #include #include #include #include -#include -#include +#include #include -#include - -// CYCLE -#include +#include namespace libbitcoin { namespace network { -namespace rpc { - -using request_body = rpc::body; -using response_body = rpc::body; - -} // rpc -} // network -} // libbitcoin - -namespace libbitcoin { -namespace network { -namespace monad { +namespace http { using empty_reader = http::empty_body::reader; using data_reader = http::chunk_body::reader; @@ -53,7 +38,6 @@ using span_reader = http::span_body::reader; using buffer_reader = http::buffer_body::reader; using string_reader = http::string_body::reader; using json_reader = http::json_body::reader; -using rpc_reader = rpc::request_body::reader; using body_reader = std::variant < std::monostate, @@ -64,7 +48,7 @@ using body_reader = std::variant buffer_reader, string_reader, json_reader, - rpc_reader + rpc::reader >; using empty_writer = http::empty_body::writer; @@ -74,7 +58,6 @@ using span_writer = http::span_body::writer; using buffer_writer = http::buffer_body::writer; using string_writer = http::string_body::writer; using json_writer = http::json_body::writer; -using rpc_writer = rpc::response_body::writer; using body_writer = std::variant < std::monostate, @@ -85,7 +68,7 @@ using body_writer = std::variant buffer_writer, string_writer, json_writer, - rpc_writer + rpc::writer >; using empty_value = http::empty_body::value_type; @@ -95,8 +78,6 @@ using span_value = http::span_body::value_type; using buffer_value = http::buffer_body::value_type; using string_value = http::string_body::value_type; using json_value = http::json_body::value_type; -using rpcin_value = rpc::request_body::value_type; -using rpcout_value = rpc::response_body::value_type; using body_value = std::variant < empty_value, @@ -106,8 +87,8 @@ using body_value = std::variant buffer_value, string_value, json_value, - rpcin_value, - rpcout_value + rpc::in_value, + rpc::out_value >; /// body template for all known message types. @@ -136,8 +117,8 @@ struct BCT_API body FORWARD_ALTERNATIVE_VARIANT_ASSIGNMENT(value_type, buffer_value, inner_) FORWARD_ALTERNATIVE_VARIANT_ASSIGNMENT(value_type, string_value, inner_) FORWARD_ALTERNATIVE_VARIANT_ASSIGNMENT(value_type, json_value, inner_) - FORWARD_ALTERNATIVE_VARIANT_ASSIGNMENT(value_type, rpcin_value, inner_) - FORWARD_ALTERNATIVE_VARIANT_ASSIGNMENT(value_type, rpcout_value, inner_) + FORWARD_ALTERNATIVE_VARIANT_ASSIGNMENT(value_type, rpc::in_value, inner_) + FORWARD_ALTERNATIVE_VARIANT_ASSIGNMENT(value_type, rpc::out_value, inner_) inline bool has_value() const NOEXCEPT { @@ -200,7 +181,7 @@ struct BCT_API body if (value_.plain_json) value = json_value{}; else - value = rpcin_value{}; + value = rpc::in_value{}; break; case http::media_type::text_plain: value = string_value{}; @@ -221,7 +202,7 @@ struct BCT_API body [&](std::monostate&) NOEXCEPT {}, [&](span_value&) NOEXCEPT {}, [&](buffer_value&) NOEXCEPT {}, - [&](rpcout_value&) NOEXCEPT {}, + [&](rpc::out_value&) NOEXCEPT {}, [&](empty_value& value) NOEXCEPT { @@ -244,10 +225,10 @@ struct BCT_API body // json_reader not copy or assignable (by contained parser). reader_.emplace(header, value); }, - [&](rpcin_value& value) NOEXCEPT + [&](rpc::in_value& value) NOEXCEPT { // json_reader not copy or assignable (by contained parser). - reader_.emplace(header, value); + reader_.emplace(header, value); } }, value.value()); } @@ -317,14 +298,14 @@ struct BCT_API body return body_writer{ std::in_place_type, header, value }; }, - [&](rpcout_value& value) NOEXCEPT + [&](rpc::out_value& value) NOEXCEPT { // json_writer is not movable (by contained serializer). // So requires in-place construction for variant populate. - return body_writer{ std::in_place_type, + return body_writer{ std::in_place_type, header, value }; }, - [&](rpcin_value&) NOEXCEPT + [&](rpc::in_value&) NOEXCEPT { return body_writer{ std::monostate{} }; } @@ -336,7 +317,7 @@ struct BCT_API body }; }; -} // namespace monad +} // namespace http } // namespace network } // namespace libbitcoin @@ -344,10 +325,9 @@ namespace libbitcoin { namespace network { namespace http { -using request = boost::beast::http::request; +using request = boost::beast::http::request; using request_cptr = std::shared_ptr; - -using response = boost::beast::http::response; +using response = boost::beast::http::response; using response_ptr = std::shared_ptr; } // namespace http diff --git a/include/bitcoin/network/messages/http/method.hpp b/include/bitcoin/network/messages/http_method.hpp similarity index 94% rename from include/bitcoin/network/messages/http/method.hpp rename to include/bitcoin/network/messages/http_method.hpp index 00a4b34b6..723815dc1 100644 --- a/include/bitcoin/network/messages/http/method.hpp +++ b/include/bitcoin/network/messages/http_method.hpp @@ -21,8 +21,7 @@ #include #include -#include -#include +#include /// Type-differentiation for request message distribution. diff --git a/include/bitcoin/network/messages/messages.hpp b/include/bitcoin/network/messages/messages.hpp index 2f59e4c0e..ba074cb2a 100644 --- a/include/bitcoin/network/messages/messages.hpp +++ b/include/bitcoin/network/messages/messages.hpp @@ -19,16 +19,11 @@ #ifndef LIBBITCOIN_NETWORK_MESSAGES_MESSAGES_HPP #define LIBBITCOIN_NETWORK_MESSAGES_MESSAGES_HPP -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include #include -#include -#include +#include +#include #endif diff --git a/include/bitcoin/network/rpc/any.hpp b/include/bitcoin/network/messages/rpc/any.hpp similarity index 97% rename from include/bitcoin/network/rpc/any.hpp rename to include/bitcoin/network/messages/rpc/any.hpp index d3c857568..7420281fa 100644 --- a/include/bitcoin/network/rpc/any.hpp +++ b/include/bitcoin/network/messages/rpc/any.hpp @@ -16,8 +16,8 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -#ifndef LIBBITCOIN_NETWORK_RPC_ANY_HPP -#define LIBBITCOIN_NETWORK_RPC_ANY_HPP +#ifndef LIBBITCOIN_NETWORK_MESSAGES_RPC_ANY_HPP +#define LIBBITCOIN_NETWORK_MESSAGES_RPC_ANY_HPP #include #include diff --git a/include/bitcoin/network/messages/rpc_body.hpp b/include/bitcoin/network/messages/rpc/body.hpp similarity index 89% rename from include/bitcoin/network/messages/rpc_body.hpp rename to include/bitcoin/network/messages/rpc/body.hpp index 64ab57915..9a227bebf 100644 --- a/include/bitcoin/network/messages/rpc_body.hpp +++ b/include/bitcoin/network/messages/rpc/body.hpp @@ -21,6 +21,7 @@ #include #include +#include namespace libbitcoin { namespace network { @@ -97,6 +98,14 @@ struct BCT_API body }; }; +// Only defines that require model.hpp, could move to independent file. +using request_body = body; +using response_body = body; +using in_value = request_body::value_type; +using out_value = response_body::value_type; +using reader = request_body::reader; +using writer = response_body::writer; + } // namespace rpc } // namespace network } // namespace libbitcoin diff --git a/include/bitcoin/network/rpc/broadcaster.hpp b/include/bitcoin/network/messages/rpc/broadcaster.hpp similarity index 94% rename from include/bitcoin/network/rpc/broadcaster.hpp rename to include/bitcoin/network/messages/rpc/broadcaster.hpp index 7d6264f8d..befca9efc 100644 --- a/include/bitcoin/network/rpc/broadcaster.hpp +++ b/include/bitcoin/network/messages/rpc/broadcaster.hpp @@ -16,13 +16,13 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -#ifndef LIBBITCOIN_NETWORK_RPC_BROADCASTER_HPP -#define LIBBITCOIN_NETWORK_RPC_BROADCASTER_HPP +#ifndef LIBBITCOIN_NETWORK_MESSAGES_RPC_BROADCASTER_HPP +#define LIBBITCOIN_NETWORK_MESSAGES_RPC_BROADCASTER_HPP #include #include #include -#include +#include namespace libbitcoin { namespace network { @@ -99,7 +99,7 @@ class broadcaster #define TEMPLATE template #define CLASS broadcaster -#include +#include #undef CLASS #undef TEMPLATE diff --git a/include/bitcoin/network/rpc/dispatcher.hpp b/include/bitcoin/network/messages/rpc/dispatcher.hpp similarity index 95% rename from include/bitcoin/network/rpc/dispatcher.hpp rename to include/bitcoin/network/messages/rpc/dispatcher.hpp index f86821a6b..3184a0631 100644 --- a/include/bitcoin/network/rpc/dispatcher.hpp +++ b/include/bitcoin/network/messages/rpc/dispatcher.hpp @@ -16,14 +16,14 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -#ifndef LIBBITCOIN_NETWORK_RPC_DISPATCHER_HPP -#define LIBBITCOIN_NETWORK_RPC_DISPATCHER_HPP +#ifndef LIBBITCOIN_NETWORK_MESSAGES_RPC_DISPATCHER_HPP +#define LIBBITCOIN_NETWORK_MESSAGES_RPC_DISPATCHER_HPP #include #include #include -#include -#include +#include +#include namespace libbitcoin { namespace network { @@ -150,7 +150,7 @@ class dispatcher #define TEMPLATE template #define CLASS dispatcher -#include +#include #undef CLASS #undef TEMPLATE diff --git a/include/bitcoin/network/rpc/enums/grouping.hpp b/include/bitcoin/network/messages/rpc/enums/grouping.hpp similarity index 91% rename from include/bitcoin/network/rpc/enums/grouping.hpp rename to include/bitcoin/network/messages/rpc/enums/grouping.hpp index c8b1a874b..cc217836b 100644 --- a/include/bitcoin/network/rpc/enums/grouping.hpp +++ b/include/bitcoin/network/messages/rpc/enums/grouping.hpp @@ -16,8 +16,8 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -#ifndef LIBBITCOIN_NETWORK_RPC_ENUMS_GROUPING_HPP -#define LIBBITCOIN_NETWORK_RPC_ENUMS_GROUPING_HPP +#ifndef LIBBITCOIN_NETWORK_MESSAGES_RPC_ENUMS_GROUPING_HPP +#define LIBBITCOIN_NETWORK_MESSAGES_RPC_ENUMS_GROUPING_HPP #include diff --git a/include/bitcoin/network/rpc/enums/version.hpp b/include/bitcoin/network/messages/rpc/enums/version.hpp similarity index 91% rename from include/bitcoin/network/rpc/enums/version.hpp rename to include/bitcoin/network/messages/rpc/enums/version.hpp index 97c68a74b..d9a6d9e97 100644 --- a/include/bitcoin/network/rpc/enums/version.hpp +++ b/include/bitcoin/network/messages/rpc/enums/version.hpp @@ -16,8 +16,8 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -#ifndef LIBBITCOIN_NETWORK_RPC_ENUMS_VERSION_HPP -#define LIBBITCOIN_NETWORK_RPC_ENUMS_VERSION_HPP +#ifndef LIBBITCOIN_NETWORK_MESSAGES_RPC_ENUMS_VERSION_HPP +#define LIBBITCOIN_NETWORK_MESSAGES_RPC_ENUMS_VERSION_HPP #include diff --git a/include/bitcoin/network/rpc/method.hpp b/include/bitcoin/network/messages/rpc/method.hpp similarity index 97% rename from include/bitcoin/network/rpc/method.hpp rename to include/bitcoin/network/messages/rpc/method.hpp index 316f62d83..d7276350e 100644 --- a/include/bitcoin/network/rpc/method.hpp +++ b/include/bitcoin/network/messages/rpc/method.hpp @@ -16,14 +16,14 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -#ifndef LIBBITCOIN_NETWORK_RPC_METHOD_HPP -#define LIBBITCOIN_NETWORK_RPC_METHOD_HPP +#ifndef LIBBITCOIN_NETWORK_MESSAGES_RPC_METHOD_HPP +#define LIBBITCOIN_NETWORK_MESSAGES_RPC_METHOD_HPP #include #include #include #include -#include +#include namespace libbitcoin { namespace network { diff --git a/include/bitcoin/network/rpc/model.hpp b/include/bitcoin/network/messages/rpc/model.hpp similarity index 96% rename from include/bitcoin/network/rpc/model.hpp rename to include/bitcoin/network/messages/rpc/model.hpp index a6d30eb3f..33ad1725c 100644 --- a/include/bitcoin/network/rpc/model.hpp +++ b/include/bitcoin/network/messages/rpc/model.hpp @@ -16,16 +16,16 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -#ifndef LIBBITCOIN_NETWORK_RPC_MODEL_HPP -#define LIBBITCOIN_NETWORK_RPC_MODEL_HPP +#ifndef LIBBITCOIN_NETWORK_MESSAGES_RPC_MODEL_HPP +#define LIBBITCOIN_NETWORK_MESSAGES_RPC_MODEL_HPP #include #include #include #include #include -#include -#include +#include +#include namespace libbitcoin { namespace network { diff --git a/include/bitcoin/network/rpc/publish.hpp b/include/bitcoin/network/messages/rpc/publish.hpp similarity index 87% rename from include/bitcoin/network/rpc/publish.hpp rename to include/bitcoin/network/messages/rpc/publish.hpp index 20d88453b..c520efc22 100644 --- a/include/bitcoin/network/rpc/publish.hpp +++ b/include/bitcoin/network/messages/rpc/publish.hpp @@ -16,14 +16,14 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -#ifndef LIBBITCOIN_NETWORK_RPC_PUBLISH_HPP -#define LIBBITCOIN_NETWORK_RPC_PUBLISH_HPP +#ifndef LIBBITCOIN_NETWORK_MESSAGES_RPC_PUBLISH_HPP +#define LIBBITCOIN_NETWORK_MESSAGES_RPC_PUBLISH_HPP #include #include #include -#include -#include +#include +#include namespace libbitcoin { namespace network { diff --git a/include/bitcoin/network/messages/rpc/rpc.hpp b/include/bitcoin/network/messages/rpc/rpc.hpp new file mode 100644 index 000000000..6e28c138e --- /dev/null +++ b/include/bitcoin/network/messages/rpc/rpc.hpp @@ -0,0 +1,33 @@ +/** + * Copyright (c) 2011-2025 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +#ifndef LIBBITCOIN_NETWORK_MESSAGES_RPC_RPC_HPP +#define LIBBITCOIN_NETWORK_MESSAGES_RPC_RPC_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#endif diff --git a/include/bitcoin/network/rpc/types.hpp b/include/bitcoin/network/messages/rpc/types.hpp similarity index 98% rename from include/bitcoin/network/rpc/types.hpp rename to include/bitcoin/network/messages/rpc/types.hpp index 1c3962912..5bd509303 100644 --- a/include/bitcoin/network/rpc/types.hpp +++ b/include/bitcoin/network/messages/rpc/types.hpp @@ -16,14 +16,14 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -#ifndef LIBBITCOIN_NETWORK_RPC_TYPES_HPP -#define LIBBITCOIN_NETWORK_RPC_TYPES_HPP +#ifndef LIBBITCOIN_NETWORK_MESSAGES_RPC_TYPES_HPP +#define LIBBITCOIN_NETWORK_MESSAGES_RPC_TYPES_HPP #include #include #include #include -#include +#include namespace libbitcoin { namespace network { diff --git a/include/bitcoin/network/net.hpp b/include/bitcoin/network/net.hpp index 747788dc4..ff843ee0e 100644 --- a/include/bitcoin/network/net.hpp +++ b/include/bitcoin/network/net.hpp @@ -29,7 +29,6 @@ #include #include #include -#include #include #include diff --git a/include/bitcoin/network/net/proxy.hpp b/include/bitcoin/network/net/proxy.hpp index 7bdd13c66..a02130720 100644 --- a/include/bitcoin/network/net/proxy.hpp +++ b/include/bitcoin/network/net/proxy.hpp @@ -24,11 +24,11 @@ #include #include #include +#include #include #include #include #include -#include namespace libbitcoin { namespace network { @@ -42,8 +42,6 @@ class BCT_API proxy public: typedef std::shared_ptr ptr; typedef subscriber<> stop_subscriber; - typedef rpc::request_body::value_type rpc_in_value; - typedef rpc::response_body::value_type rpc_out_value; DELETE_COPY_MOVE(proxy); @@ -135,10 +133,10 @@ class BCT_API proxy /// ----------------------------------------------------------------------- /// Read full rpc request from the socket, handler posted to socket strand. - virtual void read(rpc_in_value& out, count_handler&& handler) NOEXCEPT; + virtual void read(rpc::in_value& out, count_handler&& handler) NOEXCEPT; /// Write full rpc response to the socket, handler posted to socket strand. - virtual void write(rpc_out_value&& in, count_handler&& handler) NOEXCEPT; + virtual void write(rpc::out_value&& in, count_handler&& handler) NOEXCEPT; /// HTTP (generic). /// ----------------------------------------------------------------------- diff --git a/include/bitcoin/network/net/socket.hpp b/include/bitcoin/network/net/socket.hpp index de8baadf1..8755e5012 100644 --- a/include/bitcoin/network/net/socket.hpp +++ b/include/bitcoin/network/net/socket.hpp @@ -27,7 +27,6 @@ #include #include #include -#include namespace libbitcoin { namespace network { @@ -41,8 +40,6 @@ class BCT_API socket { public: typedef std::shared_ptr ptr; - typedef rpc::request_body::value_type rpc_in_value; - typedef rpc::response_body::value_type rpc_out_value; DELETE_COPY_MOVE(socket); @@ -106,11 +103,11 @@ class BCT_API socket /// ----------------------------------------------------------------------- /// Read full rpc request from the socket, handler posted to socket strand. - virtual void rpc_read(rpc_in_value& request, + virtual void rpc_read(rpc::in_value& request, count_handler&& handler) NOEXCEPT; /// Write full rpc response to the socket, handler posted to socket strand. - virtual void rpc_write(rpc_out_value&& response, + virtual void rpc_write(rpc::out_value&& response, count_handler&& handler) NOEXCEPT; /// HTTP (generic). @@ -168,31 +165,29 @@ class BCT_API socket struct read_rpc { typedef std::shared_ptr ptr; - using rpc_reader = rpc::request_body::reader; - read_rpc(rpc_in_value& request_) NOEXCEPT + read_rpc(rpc::in_value& request_) NOEXCEPT : value{}, reader{ value } { request_ = value; } - rpc_in_value value; - rpc_reader reader; + rpc::in_value value; + rpc::reader reader; }; struct write_rpc { typedef std::shared_ptr ptr; - using rpc_writer = rpc::response_body::writer; - using out_buffer = rpc_writer::out_buffer; + using out_buffer = rpc::writer::out_buffer; - write_rpc(rpc_out_value&& response) NOEXCEPT + write_rpc(rpc::out_value&& response) NOEXCEPT : value{ std::move(response) }, writer{ value } { } - rpc_out_value value; - rpc_writer writer; + rpc::out_value value; + rpc::writer writer; }; // stop diff --git a/include/bitcoin/network/sessions/session.hpp b/include/bitcoin/network/sessions/session.hpp index 10df5a37b..b7ad69ea3 100644 --- a/include/bitcoin/network/sessions/session.hpp +++ b/include/bitcoin/network/sessions/session.hpp @@ -30,7 +30,6 @@ #include #include #include -#include #include namespace libbitcoin { diff --git a/src/channels/channel_http.cpp b/src/channels/channel_http.cpp index e9572ce3d..20e19fc4a 100644 --- a/src/channels/channel_http.cpp +++ b/src/channels/channel_http.cpp @@ -25,7 +25,6 @@ #include #include #include -#include namespace libbitcoin { namespace network { @@ -117,7 +116,7 @@ void channel_http::handle_receive(const code& ec, size_t, dispatch(request); } -// Wrap the monad request as a tagged verb request and dispatch by type. +// Wrap the http request as a tagged verb request and dispatch by type. void channel_http::dispatch(const request_cptr& request) NOEXCEPT { request_t model{}; @@ -179,11 +178,11 @@ void channel_http::handle_send(const code& ec, size_t, response_ptr&, void channel_http::assign_json_buffer(response& response) NOEXCEPT { if (const auto& body = response.body(); - body.contains()) + body.contains()) { - const auto& value = body.get(); + const auto& value = body.get(); response_buffer_->max_size(value.size_hint); - body.get().buffer = response_buffer_; + body.get().buffer = response_buffer_; } } diff --git a/src/messages/monad_body.cpp b/src/messages/http_body.cpp similarity index 95% rename from src/messages/monad_body.cpp rename to src/messages/http_body.cpp index 114cc85f2..256a63278 100644 --- a/src/messages/monad_body.cpp +++ b/src/messages/http_body.cpp @@ -16,19 +16,18 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -#include +#include #include #include namespace libbitcoin { namespace network { -namespace monad { +namespace http { -using namespace network::http; using namespace network::error; -// monad::body::reader +// http::body::reader // ---------------------------------------------------------------------------- void body::reader::init(const length_type& length, boost_code& ec) NOEXCEPT @@ -103,7 +102,7 @@ void body::reader::finish(boost_code& ec) NOEXCEPT }, reader_); } -// monad::body::writer +// http::body::writer // ---------------------------------------------------------------------------- void body::writer::init(boost_code& ec) NOEXCEPT @@ -150,6 +149,6 @@ body::writer::out_buffer body::writer::get(boost_code& ec) NOEXCEPT }, writer_); } -} // namespace monad +} // namespace http } // namespace network } // namespace libbitcoin diff --git a/src/messages/rpc_body.cpp b/src/messages/rpc/body.cpp similarity index 98% rename from src/messages/rpc_body.cpp rename to src/messages/rpc/body.cpp index 3ad7f1048..b7c32ec28 100644 --- a/src/messages/rpc_body.cpp +++ b/src/messages/rpc/body.cpp @@ -16,14 +16,14 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -#include +#include #include #include #include #include #include -#include +////#include namespace libbitcoin { namespace network { diff --git a/src/rpc/model.cpp b/src/messages/rpc/model.cpp similarity index 98% rename from src/rpc/model.cpp rename to src/messages/rpc/model.cpp index 3f40d659a..79003fae9 100644 --- a/src/rpc/model.cpp +++ b/src/messages/rpc/model.cpp @@ -16,11 +16,11 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -#include +#include #include #include -#include +#include // boost::json parse/seralize is not exception safe. diff --git a/src/net/proxy.cpp b/src/net/proxy.cpp index e1010c97e..369a77281 100644 --- a/src/net/proxy.cpp +++ b/src/net/proxy.cpp @@ -25,7 +25,6 @@ #include #include #include -#include namespace libbitcoin { namespace network { @@ -205,7 +204,7 @@ void proxy::write(const asio::const_buffer& buffer, // TCP-RPC. // ---------------------------------------------------------------------------- -void proxy::read(rpc_in_value& out, count_handler&& handler) NOEXCEPT +void proxy::read(rpc::in_value& out, count_handler&& handler) NOEXCEPT { boost::asio::dispatch(strand(), std::bind(&proxy::waiting, shared_from_this())); @@ -213,7 +212,7 @@ void proxy::read(rpc_in_value& out, count_handler&& handler) NOEXCEPT socket_->rpc_read(out, std::move(handler)); } -void proxy::write(rpc_out_value&& in, count_handler&& handler) NOEXCEPT +void proxy::write(rpc::out_value&& in, count_handler&& handler) NOEXCEPT { socket_->rpc_write(std::move(in), std::move(handler)); diff --git a/src/net/socket.cpp b/src/net/socket.cpp index 41f25003c..eec8554b8 100644 --- a/src/net/socket.cpp +++ b/src/net/socket.cpp @@ -25,7 +25,6 @@ #include #include #include -#include namespace libbitcoin { namespace network { @@ -280,7 +279,7 @@ void socket::write(const asio::const_buffer& in, /// TCP-RPC. // ---------------------------------------------------------------------------- -void socket::rpc_read(rpc_in_value& request, count_handler&& handler) NOEXCEPT +void socket::rpc_read(rpc::in_value& request, count_handler&& handler) NOEXCEPT { boost_code ec{}; const auto in = emplace_shared(request); @@ -291,7 +290,7 @@ void socket::rpc_read(rpc_in_value& request, count_handler&& handler) NOEXCEPT shared_from_this(), ec, zero, in, std::move(handler))); } -void socket::rpc_write(rpc_out_value&& response, +void socket::rpc_write(rpc::out_value&& response, count_handler&& handler) NOEXCEPT { boost_code ec{}; @@ -414,7 +413,7 @@ void socket::do_rpc_read(boost_code ec, size_t total, const read_rpc::ptr& in, const count_handler& handler) NOEXCEPT { BC_ASSERT(stranded()); - constexpr auto size = write_rpc::rpc_writer::default_buffer; + constexpr auto size = rpc::writer::default_buffer; if (ec) { diff --git a/src/settings.cpp b/src/settings.cpp index 792da5884..3d8d98ff9 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -22,7 +22,6 @@ #include #include #include -#include namespace libbitcoin { namespace network { diff --git a/test/messages/monad_body_reader.cpp b/test/messages/http_body_reader.cpp similarity index 82% rename from test/messages/monad_body_reader.cpp rename to test/messages/http_body_reader.cpp index 67a2af167..fc066a5c5 100644 --- a/test/messages/monad_body_reader.cpp +++ b/test/messages/http_body_reader.cpp @@ -21,7 +21,7 @@ #if defined(HAVE_SLOW_TESTS) using namespace http; -using namespace network::monad; +using namespace network::http; struct accessor : public body::reader @@ -31,9 +31,9 @@ struct accessor using base::to_reader; }; -BOOST_AUTO_TEST_SUITE(monad_body_reader_tests) +BOOST_AUTO_TEST_SUITE(http_body_reader_tests) -BOOST_AUTO_TEST_CASE(monad_body_reader__to_reader__bogus__constructs_empty_reader) +BOOST_AUTO_TEST_CASE(http_body_reader__to_reader__bogus__constructs_empty_reader) { message_header header{}; header.set(http::field::content_type, "bogus"); @@ -43,7 +43,7 @@ BOOST_AUTO_TEST_CASE(monad_body_reader__to_reader__bogus__constructs_empty_reade BOOST_REQUIRE(std::holds_alternative(variant)); } -BOOST_AUTO_TEST_CASE(monad_body_reader__to_reader__json__constructs_json_reader) +BOOST_AUTO_TEST_CASE(http_body_reader__to_reader__json__constructs_json_reader) { message_header header{}; header.set(http::field::content_type, "application/json"); @@ -53,7 +53,7 @@ BOOST_AUTO_TEST_CASE(monad_body_reader__to_reader__json__constructs_json_reader) BOOST_REQUIRE(std::holds_alternative(variant)); } -BOOST_AUTO_TEST_CASE(monad_body_reader__to_reader__application_octet_stream__constructs_data_reader) +BOOST_AUTO_TEST_CASE(http_body_reader__to_reader__application_octet_stream__constructs_data_reader) { message_header header{}; header.set(http::field::content_type, "application/octet-stream"); @@ -64,7 +64,7 @@ BOOST_AUTO_TEST_CASE(monad_body_reader__to_reader__application_octet_stream__con BOOST_REQUIRE(std::holds_alternative(variant)); } -BOOST_AUTO_TEST_CASE(monad_body_reader__to_reader__application_octet_stream_with_attachment__constructs_file_reader) +BOOST_AUTO_TEST_CASE(http_body_reader__to_reader__application_octet_stream_with_attachment__constructs_file_reader) { message_header header{}; header.set(http::field::content_type, "application/octet-stream"); @@ -75,7 +75,7 @@ BOOST_AUTO_TEST_CASE(monad_body_reader__to_reader__application_octet_stream_with BOOST_REQUIRE(std::holds_alternative(variant)); } -BOOST_AUTO_TEST_CASE(monad_body_reader__to_reader__application_octet_stream_with_dirty_attachment__constructs_file_reader) +BOOST_AUTO_TEST_CASE(http_body_reader__to_reader__application_octet_stream_with_dirty_attachment__constructs_file_reader) { message_header header{}; header.set(http::field::content_type, "application/octet-stream"); @@ -86,7 +86,7 @@ BOOST_AUTO_TEST_CASE(monad_body_reader__to_reader__application_octet_stream_with BOOST_REQUIRE(std::holds_alternative(variant)); } -BOOST_AUTO_TEST_CASE(monad_body_reader__to_reader__text_plain__constructs_string_reader) +BOOST_AUTO_TEST_CASE(http_body_reader__to_reader__text_plain__constructs_string_reader) { message_header header{}; header.set(http::field::content_type, "text/plain"); diff --git a/test/messages/monad_body_writer.cpp b/test/messages/http_body_writer.cpp similarity index 81% rename from test/messages/monad_body_writer.cpp rename to test/messages/http_body_writer.cpp index d1e72f7c9..183502f19 100644 --- a/test/messages/monad_body_writer.cpp +++ b/test/messages/http_body_writer.cpp @@ -21,7 +21,7 @@ #if defined(HAVE_SLOW_TESTS) using namespace http; -using namespace network::monad; +using namespace network::http; struct accessor : public body::writer @@ -31,9 +31,9 @@ struct accessor using base::to_writer; }; -BOOST_AUTO_TEST_SUITE(monad_body_writer_tests) +BOOST_AUTO_TEST_SUITE(http_body_writer_tests) -BOOST_AUTO_TEST_CASE(monad_body_writer__to_writer__undefined__constructs_empty_writer) +BOOST_AUTO_TEST_CASE(http_body_writer__to_writer__undefined__constructs_empty_writer) { message_header header{}; body::value_type value{}; @@ -42,7 +42,7 @@ BOOST_AUTO_TEST_CASE(monad_body_writer__to_writer__undefined__constructs_empty_w BOOST_REQUIRE(std::holds_alternative(variant)); } -BOOST_AUTO_TEST_CASE(monad_body_writer__to_writer__empty__constructs_empty_writer) +BOOST_AUTO_TEST_CASE(http_body_writer__to_writer__empty__constructs_empty_writer) { message_header header{}; body::value_type value{}; @@ -51,7 +51,7 @@ BOOST_AUTO_TEST_CASE(monad_body_writer__to_writer__empty__constructs_empty_write BOOST_REQUIRE(std::holds_alternative(variant)); } -BOOST_AUTO_TEST_CASE(monad_body_writer__to_writer__json__constructs_json_writer) +BOOST_AUTO_TEST_CASE(http_body_writer__to_writer__json__constructs_json_writer) { message_header header{}; body::value_type value{}; @@ -60,7 +60,7 @@ BOOST_AUTO_TEST_CASE(monad_body_writer__to_writer__json__constructs_json_writer) BOOST_REQUIRE(std::holds_alternative(variant)); } -BOOST_AUTO_TEST_CASE(monad_body_writer__to_writer__data__constructs_data_writer) +BOOST_AUTO_TEST_CASE(http_body_writer__to_writer__data__constructs_data_writer) { message_header header{}; body::value_type value{}; @@ -69,7 +69,7 @@ BOOST_AUTO_TEST_CASE(monad_body_writer__to_writer__data__constructs_data_writer) BOOST_REQUIRE(std::holds_alternative(variant)); } -BOOST_AUTO_TEST_CASE(monad_body_writer__to_writer__span__constructs_span_writer) +BOOST_AUTO_TEST_CASE(http_body_writer__to_writer__span__constructs_span_writer) { message_header header{}; body::value_type value{}; @@ -78,7 +78,7 @@ BOOST_AUTO_TEST_CASE(monad_body_writer__to_writer__span__constructs_span_writer) BOOST_REQUIRE(std::holds_alternative(variant)); } -BOOST_AUTO_TEST_CASE(monad_body_writer__to_writer__buffer__constructs_buffer_writer) +BOOST_AUTO_TEST_CASE(http_body_writer__to_writer__buffer__constructs_buffer_writer) { message_header header{}; body::value_type value{}; @@ -87,7 +87,7 @@ BOOST_AUTO_TEST_CASE(monad_body_writer__to_writer__buffer__constructs_buffer_wri BOOST_REQUIRE(std::holds_alternative(variant)); } -BOOST_AUTO_TEST_CASE(monad_body_writer__to_writer__string__constructs_string_writer) +BOOST_AUTO_TEST_CASE(http_body_writer__to_writer__string__constructs_string_writer) { message_header header{}; body::value_type value{}; @@ -100,7 +100,7 @@ BOOST_AUTO_TEST_SUITE_END() BOOST_FIXTURE_TEST_SUITE(variant_body_writer_file_body_tests, test::directory_setup_fixture) -BOOST_AUTO_TEST_CASE(monad_body_writer__to_writer__file__constructs_file_writer) +BOOST_AUTO_TEST_CASE(http_body_writer__to_writer__file__constructs_file_writer) { // In dubug builds boost asserts that the file is open. // BOOST_ASSERT(body_.file_.is_open()); diff --git a/test/rpc/any.cpp b/test/messages/rpc/any.cpp similarity index 99% rename from test/rpc/any.cpp rename to test/messages/rpc/any.cpp index 617b603ac..49eea0ead 100644 --- a/test/rpc/any.cpp +++ b/test/messages/rpc/any.cpp @@ -16,7 +16,7 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -#include "../test.hpp" +#include "../../test.hpp" BOOST_AUTO_TEST_SUITE(any_tests) diff --git a/test/messages/rpc_body_reader.cpp b/test/messages/rpc/body_reader.cpp similarity index 99% rename from test/messages/rpc_body_reader.cpp rename to test/messages/rpc/body_reader.cpp index 1c25dbc43..b98af0309 100644 --- a/test/messages/rpc_body_reader.cpp +++ b/test/messages/rpc/body_reader.cpp @@ -16,7 +16,7 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -#include "../test.hpp" +#include "../../test.hpp" #if defined(HAVE_SLOW_TESTS) diff --git a/test/messages/rpc_body_writer.cpp b/test/messages/rpc/body_writer.cpp similarity index 99% rename from test/messages/rpc_body_writer.cpp rename to test/messages/rpc/body_writer.cpp index e69548485..d5b9b27f7 100644 --- a/test/messages/rpc_body_writer.cpp +++ b/test/messages/rpc/body_writer.cpp @@ -16,7 +16,7 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -#include "../test.hpp" +#include "../../test.hpp" #if defined(HAVE_SLOW_TESTS) diff --git a/test/rpc/broadcaster.cpp b/test/messages/rpc/broadcaster.cpp similarity index 99% rename from test/rpc/broadcaster.cpp rename to test/messages/rpc/broadcaster.cpp index 31177c242..fbf7179d3 100644 --- a/test/rpc/broadcaster.cpp +++ b/test/messages/rpc/broadcaster.cpp @@ -16,7 +16,7 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -#include "../test.hpp" +#include "../../test.hpp" BOOST_AUTO_TEST_SUITE(broadcaster_tests) diff --git a/test/rpc/dispatcher.cpp b/test/messages/rpc/dispatcher.cpp similarity index 99% rename from test/rpc/dispatcher.cpp rename to test/messages/rpc/dispatcher.cpp index 8dd087c61..c3380dd3d 100644 --- a/test/rpc/dispatcher.cpp +++ b/test/messages/rpc/dispatcher.cpp @@ -16,7 +16,7 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -#include "../test.hpp" +#include "../../test.hpp" BOOST_AUTO_TEST_SUITE(dispatcher_tests) diff --git a/test/rpc/method.cpp b/test/messages/rpc/method.cpp similarity index 99% rename from test/rpc/method.cpp rename to test/messages/rpc/method.cpp index bef633dc3..01e2a4d2e 100644 --- a/test/rpc/method.cpp +++ b/test/messages/rpc/method.cpp @@ -16,7 +16,7 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -#include "../test.hpp" +#include "../../test.hpp" using namespace network::rpc; diff --git a/test/rpc/types.cpp b/test/messages/rpc/types.cpp similarity index 99% rename from test/rpc/types.cpp rename to test/messages/rpc/types.cpp index c7b1641c0..5a6c11921 100644 --- a/test/rpc/types.cpp +++ b/test/messages/rpc/types.cpp @@ -16,7 +16,7 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -#include "../test.hpp" +#include "../../test.hpp" using namespace rpc;