Skip to content

Commit a3dfe52

Browse files
committed
Stub in channel_rpc, protocol_rpc/electrum/stratum_v1.
1 parent 1986b75 commit a3dfe52

File tree

11 files changed

+130
-19
lines changed

11 files changed

+130
-19
lines changed

Makefile.am

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ include_bitcoin_node_channels_HEADERS = \
183183
include/bitcoin/node/channels/channel.hpp \
184184
include/bitcoin/node/channels/channel_http.hpp \
185185
include/bitcoin/node/channels/channel_peer.hpp \
186+
include/bitcoin/node/channels/channel_rpc.hpp \
186187
include/bitcoin/node/channels/channel_tcp.hpp \
187188
include/bitcoin/node/channels/channel_ws.hpp \
188189
include/bitcoin/node/channels/channels.hpp
@@ -246,6 +247,7 @@ include_bitcoin_node_protocols_HEADERS = \
246247
include/bitcoin/node/protocols/protocol_observer.hpp \
247248
include/bitcoin/node/protocols/protocol_peer.hpp \
248249
include/bitcoin/node/protocols/protocol_performer.hpp \
250+
include/bitcoin/node/protocols/protocol_rpc.hpp \
249251
include/bitcoin/node/protocols/protocol_stratum_v1.hpp \
250252
include/bitcoin/node/protocols/protocol_stratum_v2.hpp \
251253
include/bitcoin/node/protocols/protocol_tcp.hpp \

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@
175175
<ClInclude Include="..\..\..\..\include\bitcoin\node\channels\channel.hpp" />
176176
<ClInclude Include="..\..\..\..\include\bitcoin\node\channels\channel_http.hpp" />
177177
<ClInclude Include="..\..\..\..\include\bitcoin\node\channels\channel_peer.hpp" />
178+
<ClInclude Include="..\..\..\..\include\bitcoin\node\channels\channel_rpc.hpp" />
178179
<ClInclude Include="..\..\..\..\include\bitcoin\node\channels\channel_tcp.hpp" />
179180
<ClInclude Include="..\..\..\..\include\bitcoin\node\channels\channel_ws.hpp" />
180181
<ClInclude Include="..\..\..\..\include\bitcoin\node\channels\channels.hpp" />
@@ -229,6 +230,7 @@
229230
<ClInclude Include="..\..\..\..\include\bitcoin\node\protocols\protocol_observer.hpp" />
230231
<ClInclude Include="..\..\..\..\include\bitcoin\node\protocols\protocol_peer.hpp" />
231232
<ClInclude Include="..\..\..\..\include\bitcoin\node\protocols\protocol_performer.hpp" />
233+
<ClInclude Include="..\..\..\..\include\bitcoin\node\protocols\protocol_rpc.hpp" />
232234
<ClInclude Include="..\..\..\..\include\bitcoin\node\protocols\protocol_stratum_v1.hpp" />
233235
<ClInclude Include="..\..\..\..\include\bitcoin\node\protocols\protocol_stratum_v2.hpp" />
234236
<ClInclude Include="..\..\..\..\include\bitcoin\node\protocols\protocol_tcp.hpp" />

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,9 @@
221221
<ClInclude Include="..\..\..\..\include\bitcoin\node\channels\channel_peer.hpp">
222222
<Filter>include\bitcoin\node\channels</Filter>
223223
</ClInclude>
224+
<ClInclude Include="..\..\..\..\include\bitcoin\node\channels\channel_rpc.hpp">
225+
<Filter>include\bitcoin\node\channels</Filter>
226+
</ClInclude>
224227
<ClInclude Include="..\..\..\..\include\bitcoin\node\channels\channel_tcp.hpp">
225228
<Filter>include\bitcoin\node\channels</Filter>
226229
</ClInclude>
@@ -383,6 +386,9 @@
383386
<ClInclude Include="..\..\..\..\include\bitcoin\node\protocols\protocol_performer.hpp">
384387
<Filter>include\bitcoin\node\protocols</Filter>
385388
</ClInclude>
389+
<ClInclude Include="..\..\..\..\include\bitcoin\node\protocols\protocol_rpc.hpp">
390+
<Filter>include\bitcoin\node\protocols</Filter>
391+
</ClInclude>
386392
<ClInclude Include="..\..\..\..\include\bitcoin\node\protocols\protocol_stratum_v1.hpp">
387393
<Filter>include\bitcoin\node\protocols</Filter>
388394
</ClInclude>

include/bitcoin/node.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include <bitcoin/node/channels/channel.hpp>
3131
#include <bitcoin/node/channels/channel_http.hpp>
3232
#include <bitcoin/node/channels/channel_peer.hpp>
33+
#include <bitcoin/node/channels/channel_rpc.hpp>
3334
#include <bitcoin/node/channels/channel_tcp.hpp>
3435
#include <bitcoin/node/channels/channel_ws.hpp>
3536
#include <bitcoin/node/channels/channels.hpp>
@@ -77,6 +78,7 @@
7778
#include <bitcoin/node/protocols/protocol_observer.hpp>
7879
#include <bitcoin/node/protocols/protocol_peer.hpp>
7980
#include <bitcoin/node/protocols/protocol_performer.hpp>
81+
#include <bitcoin/node/protocols/protocol_rpc.hpp>
8082
#include <bitcoin/node/protocols/protocol_stratum_v1.hpp>
8183
#include <bitcoin/node/protocols/protocol_stratum_v2.hpp>
8284
#include <bitcoin/node/protocols/protocol_tcp.hpp>
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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_NODE_CHANNELS_CHANNEL_RPC_HPP
20+
#define LIBBITCOIN_NODE_CHANNELS_CHANNEL_RPC_HPP
21+
22+
#include <memory>
23+
#include <bitcoin/node/channels/channel.hpp>
24+
#include <bitcoin/node/configuration.hpp>
25+
#include <bitcoin/node/define.hpp>
26+
27+
namespace libbitcoin {
28+
namespace node {
29+
30+
/// Channel for electrum and stratum v1 channels (non-http json-rpc).
31+
class BCN_API channel_rpc
32+
: public node::channel,
33+
public network::channel_rpc,
34+
protected network::tracker<channel_rpc>
35+
{
36+
public:
37+
typedef std::shared_ptr<channel_rpc> ptr;
38+
39+
inline channel_rpc(const network::logger& log,
40+
const network::socket::ptr& socket, uint64_t identifier,
41+
const node::configuration& config, const options_t& options) NOEXCEPT
42+
: node::channel(log, socket, identifier, config),
43+
network::channel_rpc(log, socket, identifier, config.network, options),
44+
network::tracker<channel_rpc>(log)
45+
{
46+
}
47+
};
48+
49+
} // namespace node
50+
} // namespace libbitcoin
51+
52+
#endif

include/bitcoin/node/channels/channel_tcp.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ namespace libbitcoin {
2828
namespace node {
2929

3030
/// Abstract base TCP channel state for the node.
31-
/// This is a placeholder for electrum, bitcoind, and stratum v1/v2 channels.
31+
/// This is a placeholder for stratum v2 (any unimplemented).
3232
class BCN_API channel_tcp
3333
: public node::channel,
3434
public network::channel,

include/bitcoin/node/channels/channels.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@
2020
#define LIBBITCOIN_NODE_CHANNELS_CHANNELS_HPP
2121

2222
#include <bitcoin/node/channels/channel.hpp>
23+
#include <bitcoin/node/channels/channel_http.hpp>
2324
#include <bitcoin/node/channels/channel_peer.hpp>
25+
#include <bitcoin/node/channels/channel_rpc.hpp>
2426
#include <bitcoin/node/channels/channel_tcp.hpp>
25-
#include <bitcoin/node/channels/channel_http.hpp>
2627
#include <bitcoin/node/channels/channel_ws.hpp>
2728

2829
#endif

include/bitcoin/node/protocols/protocol_electrum.hpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@
2222
#include <memory>
2323
#include <bitcoin/node/channels/channels.hpp>
2424
#include <bitcoin/node/define.hpp>
25-
#include <bitcoin/node/protocols/protocol_tcp.hpp>
25+
#include <bitcoin/node/protocols/protocol_rpc.hpp>
2626

2727
namespace libbitcoin {
2828
namespace node {
2929

3030
class BCN_API protocol_electrum
31-
: public node::protocol_tcp,
31+
: public node::protocol_rpc,
3232
protected network::tracker<protocol_electrum>
3333
{
3434
public:
@@ -37,20 +37,16 @@ class BCN_API protocol_electrum
3737
inline protocol_electrum(const auto& session,
3838
const network::channel::ptr& channel,
3939
const options_t& options) NOEXCEPT
40-
: node::protocol_tcp(session, channel, options),
40+
: node::protocol_rpc(session, channel, options),
4141
network::tracker<protocol_electrum>(session->log)
4242
{
4343
}
4444

4545
/// Public start is required.
4646
inline void start() NOEXCEPT override
4747
{
48-
node::protocol_tcp::start();
48+
node::protocol_rpc::start();
4949
}
50-
51-
private:
52-
// This is thread safe.
53-
////const options_t& options_;
5450
};
5551

5652
} // namespace node
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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_NODE_PROTOCOLS_PROTOCOL_RPC_HPP
20+
#define LIBBITCOIN_NODE_PROTOCOLS_PROTOCOL_RPC_HPP
21+
22+
#include <memory>
23+
#include <bitcoin/node/channels/channels.hpp>
24+
#include <bitcoin/node/define.hpp>
25+
#include <bitcoin/node/protocols/protocol.hpp>
26+
27+
// Only session.hpp.
28+
#include <bitcoin/node/sessions/session.hpp>
29+
30+
namespace libbitcoin {
31+
namespace node {
32+
33+
/// Abstract base for RPC protocols, thread safe.
34+
class BCN_API protocol_rpc
35+
: public node::protocol,
36+
public network::protocol_rpc
37+
{
38+
public:
39+
using channel_t = node::channel_rpc;
40+
41+
protected:
42+
inline protocol_rpc(const auto& session,
43+
const network::channel::ptr& channel,
44+
const options_t& options) NOEXCEPT
45+
: node::protocol(session, channel),
46+
network::protocol_rpc(session, channel, options)
47+
{
48+
}
49+
};
50+
51+
} // namespace node
52+
} // namespace libbitcoin
53+
54+
#endif

include/bitcoin/node/protocols/protocol_stratum_v1.hpp

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@
2121

2222
#include <memory>
2323
#include <bitcoin/node/define.hpp>
24-
#include <bitcoin/node/protocols/protocol_tcp.hpp>
24+
#include <bitcoin/node/protocols/protocol_rpc.hpp>
2525

2626
namespace libbitcoin {
2727
namespace node {
2828

2929
class BCN_API protocol_stratum_v1
30-
: public node::protocol_tcp,
30+
: public node::protocol_rpc,
3131
protected network::tracker<protocol_stratum_v1>
3232
{
3333
public:
@@ -36,21 +36,16 @@ class BCN_API protocol_stratum_v1
3636
protocol_stratum_v1(const auto& session,
3737
const network::channel::ptr& channel,
3838
const options_t& options) NOEXCEPT
39-
: node::protocol_tcp(session, channel, options),
40-
////options_(options),
39+
: node::protocol_rpc(session, channel, options),
4140
network::tracker<protocol_stratum_v1>(session->log)
4241
{
4342
}
4443

4544
/// Public start is required.
4645
void start() NOEXCEPT override
4746
{
48-
node::protocol_tcp::start();
47+
node::protocol_rpc::start();
4948
}
50-
51-
private:
52-
// This is thread safe.
53-
////const options_t& options_;
5449
};
5550

5651
} // namespace node

0 commit comments

Comments
 (0)