Skip to content

Commit 105388e

Browse files
authored
Merge pull request #939 from evoskuil/master
Stub in channel_rpc, protocol_rpc/electrum/stratum_v1.
2 parents 1986b75 + 98dac89 commit 105388e

File tree

15 files changed

+136
-25
lines changed

15 files changed

+136
-25
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/interfaces/electrum.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ struct electrum_methods
3131
static constexpr std::tuple methods
3232
{
3333
/// Blockchain methods.
34-
method<"blockchain.block.header", number_t, optional<0>>{ "height", "cp_height" },
35-
method<"blockchain.block.headers", number_t, number_t, optional<0>>{ "start_height", "count", "cp_height" },
34+
method<"blockchain.block.header", number_t, optional<0.0>>{ "height", "cp_height" },
35+
method<"blockchain.block.headers", number_t, number_t, optional<0.0>>{ "start_height", "count", "cp_height" },
3636
method<"blockchain.estimatefee", number_t>{ "number" },
3737
method<"blockchain.headers.subscribe">{},
3838
method<"blockchain.relayfee">{},

include/bitcoin/node/interfaces/stratum_v1.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ struct stratum_v1_methods
3131
static constexpr std::tuple methods
3232
{
3333
/// Client requests.
34-
method<"mining.subscribe", optional<""_t>, optional<0>>{ "user_agent", "extranonce1_size" },
34+
method<"mining.subscribe", optional<""_t>, optional<0.0>>{ "user_agent", "extranonce1_size" },
3535
method<"mining.authorize", string_t, string_t>{ "username", "password" },
3636
method<"mining.submit", string_t, string_t, string_t, number_t, string_t>{ "worker_name", "job_id", "extranonce2", "ntime", "nonce" },
3737
method<"mining.extranonce.subscribe">{},

include/bitcoin/node/protocols/protocol.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class BCN_API protocol
4040
/// -----------------------------------------------------------------------
4141

4242
// reinterpret_pointer_cast because channel is abstract.
43-
protocol(const auto& session,
43+
inline protocol(const auto& session,
4444
const network::channel::ptr& channel) NOEXCEPT
4545
: channel_(std::reinterpret_pointer_cast<node::channel>(channel)),
4646
session_(session)

0 commit comments

Comments
 (0)