Skip to content

Commit ee545a7

Browse files
authored
Merge pull request #677 from evoskuil/master
Implement json-rpc over tcp socket/proxy methods.
2 parents 7e1484e + 8e225e9 commit ee545a7

File tree

22 files changed

+377
-101
lines changed

22 files changed

+377
-101
lines changed

Makefile.am

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ src_libbitcoin_network_la_SOURCES = \
4545
src/channels/channel.cpp \
4646
src/channels/channel_http.cpp \
4747
src/channels/channel_peer.cpp \
48+
src/channels/channel_rpc.cpp \
4849
src/channels/channel_ws.cpp \
4950
src/config/address.cpp \
5051
src/config/authority.cpp \
@@ -160,6 +161,7 @@ test_libbitcoin_network_test_SOURCES = \
160161
test/channels/channel.cpp \
161162
test/channels/channel_http.cpp \
162163
test/channels/channel_peer.cpp \
164+
test/channels/channel_rpc.cpp \
163165
test/channels/channel_ws.cpp \
164166
test/config/address.cpp \
165167
test/config/authority.cpp \
@@ -302,6 +304,7 @@ include_bitcoin_network_channels_HEADERS = \
302304
include/bitcoin/network/channels/channel.hpp \
303305
include/bitcoin/network/channels/channel_http.hpp \
304306
include/bitcoin/network/channels/channel_peer.hpp \
307+
include/bitcoin/network/channels/channel_rpc.hpp \
305308
include/bitcoin/network/channels/channel_ws.hpp \
306309
include/bitcoin/network/channels/channels.hpp
307310

@@ -450,6 +453,7 @@ include_bitcoin_network_protocols_HEADERS = \
450453
include/bitcoin/network/protocols/protocol_ping_106.hpp \
451454
include/bitcoin/network/protocols/protocol_ping_60001.hpp \
452455
include/bitcoin/network/protocols/protocol_reject_70002.hpp \
456+
include/bitcoin/network/protocols/protocol_rpc.hpp \
453457
include/bitcoin/network/protocols/protocol_seed_209.hpp \
454458
include/bitcoin/network/protocols/protocol_version_106.hpp \
455459
include/bitcoin/network/protocols/protocol_version_70001.hpp \

builds/cmake/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ add_library( ${CANONICAL_LIB_NAME}
227227
"../../src/channels/channel.cpp"
228228
"../../src/channels/channel_http.cpp"
229229
"../../src/channels/channel_peer.cpp"
230+
"../../src/channels/channel_rpc.cpp"
230231
"../../src/channels/channel_ws.cpp"
231232
"../../src/config/address.cpp"
232233
"../../src/config/authority.cpp"
@@ -366,6 +367,7 @@ if (with-tests)
366367
"../../test/channels/channel.cpp"
367368
"../../test/channels/channel_http.cpp"
368369
"../../test/channels/channel_peer.cpp"
370+
"../../test/channels/channel_rpc.cpp"
369371
"../../test/channels/channel_ws.cpp"
370372
"../../test/config/address.cpp"
371373
"../../test/config/authority.cpp"

builds/msvc/vs2022/libbitcoin-network-test/libbitcoin-network-test.vcxproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@
133133
<ClCompile Include="..\..\..\..\test\channels\channel.cpp" />
134134
<ClCompile Include="..\..\..\..\test\channels\channel_http.cpp" />
135135
<ClCompile Include="..\..\..\..\test\channels\channel_peer.cpp" />
136+
<ClCompile Include="..\..\..\..\test\channels\channel_rpc.cpp" />
136137
<ClCompile Include="..\..\..\..\test\channels\channel_ws.cpp" />
137138
<ClCompile Include="..\..\..\..\test\config\address.cpp">
138139
<ObjectFileName>$(IntDir)test_config_address.obj</ObjectFileName>

builds/msvc/vs2022/libbitcoin-network-test/libbitcoin-network-test.vcxproj.filters

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@
102102
<ClCompile Include="..\..\..\..\test\channels\channel_peer.cpp">
103103
<Filter>src\channels</Filter>
104104
</ClCompile>
105+
<ClCompile Include="..\..\..\..\test\channels\channel_rpc.cpp">
106+
<Filter>src\channels</Filter>
107+
</ClCompile>
105108
<ClCompile Include="..\..\..\..\test\channels\channel_ws.cpp">
106109
<Filter>src\channels</Filter>
107110
</ClCompile>

builds/msvc/vs2022/libbitcoin-network/libbitcoin-network.vcxproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@
127127
<ClCompile Include="..\..\..\..\src\channels\channel.cpp" />
128128
<ClCompile Include="..\..\..\..\src\channels\channel_http.cpp" />
129129
<ClCompile Include="..\..\..\..\src\channels\channel_peer.cpp" />
130+
<ClCompile Include="..\..\..\..\src\channels\channel_rpc.cpp" />
130131
<ClCompile Include="..\..\..\..\src\channels\channel_ws.cpp" />
131132
<ClCompile Include="..\..\..\..\src\config\address.cpp">
132133
<ObjectFileName>$(IntDir)src_config_address.obj</ObjectFileName>
@@ -241,6 +242,7 @@
241242
<ClInclude Include="..\..\..\..\include\bitcoin\network\channels\channel.hpp" />
242243
<ClInclude Include="..\..\..\..\include\bitcoin\network\channels\channel_http.hpp" />
243244
<ClInclude Include="..\..\..\..\include\bitcoin\network\channels\channel_peer.hpp" />
245+
<ClInclude Include="..\..\..\..\include\bitcoin\network\channels\channel_rpc.hpp" />
244246
<ClInclude Include="..\..\..\..\include\bitcoin\network\channels\channel_ws.hpp" />
245247
<ClInclude Include="..\..\..\..\include\bitcoin\network\channels\channels.hpp" />
246248
<ClInclude Include="..\..\..\..\include\bitcoin\network\config\address.hpp" />
@@ -336,6 +338,7 @@
336338
<ClInclude Include="..\..\..\..\include\bitcoin\network\protocols\protocol_ping_106.hpp" />
337339
<ClInclude Include="..\..\..\..\include\bitcoin\network\protocols\protocol_ping_60001.hpp" />
338340
<ClInclude Include="..\..\..\..\include\bitcoin\network\protocols\protocol_reject_70002.hpp" />
341+
<ClInclude Include="..\..\..\..\include\bitcoin\network\protocols\protocol_rpc.hpp" />
339342
<ClInclude Include="..\..\..\..\include\bitcoin\network\protocols\protocol_seed_209.hpp" />
340343
<ClInclude Include="..\..\..\..\include\bitcoin\network\protocols\protocol_version_106.hpp" />
341344
<ClInclude Include="..\..\..\..\include\bitcoin\network\protocols\protocol_version_70001.hpp" />

builds/msvc/vs2022/libbitcoin-network/libbitcoin-network.vcxproj.filters

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,9 @@
147147
<ClCompile Include="..\..\..\..\src\channels\channel_peer.cpp">
148148
<Filter>src\channels</Filter>
149149
</ClCompile>
150+
<ClCompile Include="..\..\..\..\src\channels\channel_rpc.cpp">
151+
<Filter>src\channels</Filter>
152+
</ClCompile>
150153
<ClCompile Include="..\..\..\..\src\channels\channel_ws.cpp">
151154
<Filter>src\channels</Filter>
152155
</ClCompile>
@@ -473,6 +476,9 @@
473476
<ClInclude Include="..\..\..\..\include\bitcoin\network\channels\channel_peer.hpp">
474477
<Filter>include\bitcoin\network\channels</Filter>
475478
</ClInclude>
479+
<ClInclude Include="..\..\..\..\include\bitcoin\network\channels\channel_rpc.hpp">
480+
<Filter>include\bitcoin\network\channels</Filter>
481+
</ClInclude>
476482
<ClInclude Include="..\..\..\..\include\bitcoin\network\channels\channel_ws.hpp">
477483
<Filter>include\bitcoin\network\channels</Filter>
478484
</ClInclude>
@@ -758,6 +764,9 @@
758764
<ClInclude Include="..\..\..\..\include\bitcoin\network\protocols\protocol_reject_70002.hpp">
759765
<Filter>include\bitcoin\network\protocols</Filter>
760766
</ClInclude>
767+
<ClInclude Include="..\..\..\..\include\bitcoin\network\protocols\protocol_rpc.hpp">
768+
<Filter>include\bitcoin\network\protocols</Filter>
769+
</ClInclude>
761770
<ClInclude Include="..\..\..\..\include\bitcoin\network\protocols\protocol_seed_209.hpp">
762771
<Filter>include\bitcoin\network\protocols</Filter>
763772
</ClInclude>

include/bitcoin/network.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
#include <bitcoin/network/channels/channel.hpp>
4343
#include <bitcoin/network/channels/channel_http.hpp>
4444
#include <bitcoin/network/channels/channel_peer.hpp>
45+
#include <bitcoin/network/channels/channel_rpc.hpp>
4546
#include <bitcoin/network/channels/channel_ws.hpp>
4647
#include <bitcoin/network/channels/channels.hpp>
4748
#include <bitcoin/network/config/address.hpp>
@@ -133,6 +134,7 @@
133134
#include <bitcoin/network/protocols/protocol_ping_106.hpp>
134135
#include <bitcoin/network/protocols/protocol_ping_60001.hpp>
135136
#include <bitcoin/network/protocols/protocol_reject_70002.hpp>
137+
#include <bitcoin/network/protocols/protocol_rpc.hpp>
136138
#include <bitcoin/network/protocols/protocol_seed_209.hpp>
137139
#include <bitcoin/network/protocols/protocol_version_106.hpp>
138140
#include <bitcoin/network/protocols/protocol_version_70001.hpp>
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/**
2+
* Copyright (c) 2011-2025 libbitcoin developers (see AUTHORS)
3+
*
4+
* This file is part of libbitcoin.
5+
*
6+
* This program is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU Affero General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU Affero General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Affero General Public License
17+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
18+
*/
19+
#ifndef LIBBITCOIN_NETWORK_CHANNELS_CHANNEL_RPC_HPP
20+
#define LIBBITCOIN_NETWORK_CHANNELS_CHANNEL_RPC_HPP
21+
22+
#include <memory>
23+
#include <bitcoin/network/channels/channel.hpp>
24+
#include <bitcoin/network/define.hpp>
25+
#include <bitcoin/network/log/log.hpp>
26+
#include <bitcoin/network/net/net.hpp>
27+
28+
namespace libbitcoin {
29+
namespace network {
30+
31+
/// rpc over tcp channel.
32+
class BCT_API channel_rpc
33+
: public channel
34+
{
35+
public:
36+
typedef std::shared_ptr<channel_rpc> ptr;
37+
38+
inline channel_rpc(const logger& log, const socket::ptr& socket,
39+
uint64_t identifier, const settings_t& settings,
40+
const options_t& options) NOEXCEPT
41+
: channel(log, socket, identifier, settings, options)
42+
{
43+
}
44+
};
45+
46+
} // namespace network
47+
} // namespace libbitcoin
48+
49+
#endif

include/bitcoin/network/channels/channels.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <bitcoin/network/channels/channel.hpp>
2323
#include <bitcoin/network/channels/channel_http.hpp>
2424
#include <bitcoin/network/channels/channel_peer.hpp>
25+
#include <bitcoin/network/channels/channel_rpc.hpp>
2526
#include <bitcoin/network/channels/channel_ws.hpp>
2627

2728
#endif

include/bitcoin/network/error.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ BCT_API bool asio_is_canceled(const boost_code& ec) NOEXCEPT;
238238
BCT_API code asio_to_error_code(const boost_code& ec) NOEXCEPT;
239239

240240
/// 1:1 mapping of boost::beast:http::error to network (or error::unknown).
241-
BCT_API code beast_to_error_code(const boost_code& ec) NOEXCEPT;
241+
BCT_API code http_to_error_code(const boost_code& ec) NOEXCEPT;
242242

243243
} // namespace error
244244
} // namespace network

0 commit comments

Comments
 (0)