Skip to content

Commit 5d896f0

Browse files
authored
Merge pull request #621 from evoskuil/master
Add intermediate channel and session base classes, docs.
2 parents e28a284 + af6f9a5 commit 5d896f0

17 files changed

Lines changed: 279 additions & 28 deletions

Makefile.am

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ include_bitcoin_server_HEADERS = \
135135

136136
include_bitcoin_server_channelsdir = ${includedir}/bitcoin/server/channels
137137
include_bitcoin_server_channels_HEADERS = \
138+
include/bitcoin/server/channels/channel.hpp \
138139
include/bitcoin/server/channels/channel_electrum.hpp \
139140
include/bitcoin/server/channels/channel_http.hpp \
140141
include/bitcoin/server/channels/channel_stratum_v1.hpp \
@@ -184,6 +185,7 @@ include_bitcoin_server_protocols_HEADERS = \
184185

185186
include_bitcoin_server_sessionsdir = ${includedir}/bitcoin/server/sessions
186187
include_bitcoin_server_sessions_HEADERS = \
188+
include/bitcoin/server/sessions/session.hpp \
187189
include/bitcoin/server/sessions/session_handshake.hpp \
188190
include/bitcoin/server/sessions/session_server.hpp \
189191
include/bitcoin/server/sessions/sessions.hpp

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@
141141
</ItemGroup>
142142
<ItemGroup>
143143
<ClInclude Include="..\..\..\..\include\bitcoin\server.hpp" />
144+
<ClInclude Include="..\..\..\..\include\bitcoin\server\channels\channel.hpp" />
144145
<ClInclude Include="..\..\..\..\include\bitcoin\server\channels\channel_electrum.hpp" />
145146
<ClInclude Include="..\..\..\..\include\bitcoin\server\channels\channel_http.hpp" />
146147
<ClInclude Include="..\..\..\..\include\bitcoin\server\channels\channel_stratum_v1.hpp" />
@@ -179,6 +180,7 @@
179180
<ClInclude Include="..\..\..\..\include\bitcoin\server\protocols\protocol_stratum_v2.hpp" />
180181
<ClInclude Include="..\..\..\..\include\bitcoin\server\protocols\protocols.hpp" />
181182
<ClInclude Include="..\..\..\..\include\bitcoin\server\server_node.hpp" />
183+
<ClInclude Include="..\..\..\..\include\bitcoin\server\sessions\session.hpp" />
182184
<ClInclude Include="..\..\..\..\include\bitcoin\server\sessions\session_handshake.hpp" />
183185
<ClInclude Include="..\..\..\..\include\bitcoin\server\sessions\session_server.hpp" />
184186
<ClInclude Include="..\..\..\..\include\bitcoin\server\sessions\sessions.hpp" />

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@
107107
<ClInclude Include="..\..\..\..\include\bitcoin\server.hpp">
108108
<Filter>include\bitcoin</Filter>
109109
</ClInclude>
110+
<ClInclude Include="..\..\..\..\include\bitcoin\server\channels\channel.hpp">
111+
<Filter>include\bitcoin\server\channels</Filter>
112+
</ClInclude>
110113
<ClInclude Include="..\..\..\..\include\bitcoin\server\channels\channel_electrum.hpp">
111114
<Filter>include\bitcoin\server\channels</Filter>
112115
</ClInclude>
@@ -221,6 +224,9 @@
221224
<ClInclude Include="..\..\..\..\include\bitcoin\server\server_node.hpp">
222225
<Filter>include\bitcoin\server</Filter>
223226
</ClInclude>
227+
<ClInclude Include="..\..\..\..\include\bitcoin\server\sessions\session.hpp">
228+
<Filter>include\bitcoin\server\sessions</Filter>
229+
</ClInclude>
224230
<ClInclude Include="..\..\..\..\include\bitcoin\server\sessions\session_handshake.hpp">
225231
<Filter>include\bitcoin\server\sessions</Filter>
226232
</ClInclude>

console/executor_runner.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ void executor::subscribe_connect()
4646
{
4747
node_->subscribe_connect
4848
(
49-
[&](const code&, const channel::ptr&)
49+
[&](const code&, const network::channel::ptr&)
5050
{
5151
log_.write(levels::verbose) <<
5252
"{in:" << node_->inbound_channel_count() << "}"

include/bitcoin/server.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <bitcoin/server/server_node.hpp>
2323
#include <bitcoin/server/settings.hpp>
2424
#include <bitcoin/server/version.hpp>
25+
#include <bitcoin/server/channels/channel.hpp>
2526
#include <bitcoin/server/channels/channel_electrum.hpp>
2627
#include <bitcoin/server/channels/channel_http.hpp>
2728
#include <bitcoin/server/channels/channel_stratum_v1.hpp>
@@ -55,6 +56,7 @@
5556
#include <bitcoin/server/protocols/protocol_stratum_v1.hpp>
5657
#include <bitcoin/server/protocols/protocol_stratum_v2.hpp>
5758
#include <bitcoin/server/protocols/protocols.hpp>
59+
#include <bitcoin/server/sessions/session.hpp>
5860
#include <bitcoin/server/sessions/session_handshake.hpp>
5961
#include <bitcoin/server/sessions/session_server.hpp>
6062
#include <bitcoin/server/sessions/sessions.hpp>
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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_SERVER_CHANNELS_CHANNEL_HPP
20+
#define LIBBITCOIN_SERVER_CHANNELS_CHANNEL_HPP
21+
22+
#include <memory>
23+
#include <bitcoin/server/define.hpp>
24+
25+
namespace libbitcoin {
26+
namespace server {
27+
28+
/// Intermediate base class for future server injection.
29+
class BCS_API channel
30+
: public node::channel
31+
{
32+
public:
33+
typedef std::shared_ptr<channel> ptr;
34+
using base = node::channel;
35+
using base::channel;
36+
};
37+
38+
} // namespace server
39+
} // namespace libbitcoin
40+
41+
#endif

include/bitcoin/server/channels/channel_electrum.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#define LIBBITCOIN_SERVER_CHANNELS_CHANNEL_ELECTRUM_HPP
2121

2222
#include <memory>
23+
#include <bitcoin/server/channels/channel.hpp>
2324
#include <bitcoin/server/configuration.hpp>
2425
#include <bitcoin/server/define.hpp>
2526
#include <bitcoin/server/interfaces/interfaces.hpp>
@@ -31,7 +32,7 @@ namespace server {
3132
// TODO: strip extraneous args before electrum version dispatch.
3233
/// Channel for electrum channels (non-http json-rpc).
3334
class BCS_API channel_electrum
34-
: public node::channel,
35+
: public server::channel,
3536
public network::channel_rpc<interface::electrum>,
3637
protected network::tracker<channel_electrum>
3738
{
@@ -43,7 +44,7 @@ class BCS_API channel_electrum
4344
inline channel_electrum(const network::logger& log,
4445
const network::socket::ptr& socket, uint64_t identifier,
4546
const node::configuration& config, const options_t& options) NOEXCEPT
46-
: node::channel(log, socket, identifier, config),
47+
: server::channel(log, socket, identifier, config),
4748
network::channel_rpc<interface::electrum>(log, socket, identifier,
4849
config.network, options),
4950
network::tracker<channel_electrum>(log)

include/bitcoin/server/channels/channel_http.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,15 @@
2020
#define LIBBITCOIN_SERVER_CHANNELS_CHANNEL_HTTP_HPP
2121

2222
#include <memory>
23+
#include <bitcoin/server/channels/channel.hpp>
2324
#include <bitcoin/server/configuration.hpp>
2425
#include <bitcoin/server/define.hpp>
2526

2627
namespace libbitcoin {
2728
namespace server {
2829

2930
class BCS_API channel_http
30-
: public node::channel,
31+
: public server::channel,
3132
public network::channel_http,
3233
protected network::tracker<channel_http>
3334
{
@@ -37,7 +38,7 @@ class BCS_API channel_http
3738
inline channel_http(const network::logger& log,
3839
const network::socket::ptr& socket, uint64_t identifier,
3940
const node::configuration& config, const options_t& options) NOEXCEPT
40-
: node::channel(log, socket, identifier, config),
41+
: server::channel(log, socket, identifier, config),
4142
network::channel_http(log, socket, identifier, config.network, options),
4243
network::tracker<channel_http>(log)
4344
{

include/bitcoin/server/channels/channel_stratum_v1.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#define LIBBITCOIN_SERVER_CHANNELS_CHANNEL_STRATUM_V1_HPP
2121

2222
#include <memory>
23+
#include <bitcoin/server/channels/channel.hpp>
2324
#include <bitcoin/server/configuration.hpp>
2425
#include <bitcoin/server/define.hpp>
2526
#include <bitcoin/server/interfaces/interfaces.hpp>
@@ -29,7 +30,7 @@ namespace server {
2930

3031
/// Channel for stratum v1 channels (non-http json-rpc).
3132
class BCS_API channel_stratum_v1
32-
: public node::channel,
33+
: public server::channel,
3334
public network::channel_rpc<interface::stratum_v1>,
3435
protected network::tracker<channel_stratum_v1>
3536
{
@@ -41,7 +42,7 @@ class BCS_API channel_stratum_v1
4142
inline channel_stratum_v1(const network::logger& log,
4243
const network::socket::ptr& socket, uint64_t identifier,
4344
const node::configuration& config, const options_t& options) NOEXCEPT
44-
: node::channel(log, socket, identifier, config),
45+
: server::channel(log, socket, identifier, config),
4546
network::channel_rpc<interface::stratum_v1>(log, socket, identifier,
4647
config.network, options),
4748
network::tracker<channel_stratum_v1>(log)

include/bitcoin/server/channels/channel_stratum_v2.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#define LIBBITCOIN_SERVER_CHANNELS_CHANNEL_STRATUM_V2_HPP
2121

2222
#include <memory>
23+
#include <bitcoin/server/channels/channel.hpp>
2324
#include <bitcoin/server/configuration.hpp>
2425
#include <bitcoin/server/define.hpp>
2526

@@ -28,7 +29,7 @@ namespace server {
2829

2930
/// Channel for stratum v2 (custom protocol, not implemented).
3031
class BCS_API channel_stratum_v2
31-
: public node::channel,
32+
: public server::channel,
3233
public network::channel,
3334
protected network::tracker<channel_stratum_v2>
3435
{
@@ -38,7 +39,7 @@ class BCS_API channel_stratum_v2
3839
inline channel_stratum_v2(const network::logger& log,
3940
const network::socket::ptr& socket, uint64_t identifier,
4041
const node::configuration& config, const options_t& options) NOEXCEPT
41-
: node::channel(log, socket, identifier, config),
42+
: server::channel(log, socket, identifier, config),
4243
network::channel(log, socket, identifier, config.network, options),
4344
network::tracker<channel_stratum_v2>(log)
4445
{

0 commit comments

Comments
 (0)