Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ include_bitcoin_server_HEADERS = \

include_bitcoin_server_channelsdir = ${includedir}/bitcoin/server/channels
include_bitcoin_server_channels_HEADERS = \
include/bitcoin/server/channels/channel.hpp \
include/bitcoin/server/channels/channel_electrum.hpp \
include/bitcoin/server/channels/channel_http.hpp \
include/bitcoin/server/channels/channel_stratum_v1.hpp \
Expand Down Expand Up @@ -184,6 +185,7 @@ include_bitcoin_server_protocols_HEADERS = \

include_bitcoin_server_sessionsdir = ${includedir}/bitcoin/server/sessions
include_bitcoin_server_sessions_HEADERS = \
include/bitcoin/server/sessions/session.hpp \
include/bitcoin/server/sessions/session_handshake.hpp \
include/bitcoin/server/sessions/session_server.hpp \
include/bitcoin/server/sessions/sessions.hpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\..\..\include\bitcoin\server.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\server\channels\channel.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\server\channels\channel_electrum.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\server\channels\channel_http.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\server\channels\channel_stratum_v1.hpp" />
Expand Down Expand Up @@ -179,6 +180,7 @@
<ClInclude Include="..\..\..\..\include\bitcoin\server\protocols\protocol_stratum_v2.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\server\protocols\protocols.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\server\server_node.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\server\sessions\session.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\server\sessions\session_handshake.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\server\sessions\session_server.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\server\sessions\sessions.hpp" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@
<ClInclude Include="..\..\..\..\include\bitcoin\server.hpp">
<Filter>include\bitcoin</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\include\bitcoin\server\channels\channel.hpp">
<Filter>include\bitcoin\server\channels</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\include\bitcoin\server\channels\channel_electrum.hpp">
<Filter>include\bitcoin\server\channels</Filter>
</ClInclude>
Expand Down Expand Up @@ -221,6 +224,9 @@
<ClInclude Include="..\..\..\..\include\bitcoin\server\server_node.hpp">
<Filter>include\bitcoin\server</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\include\bitcoin\server\sessions\session.hpp">
<Filter>include\bitcoin\server\sessions</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\include\bitcoin\server\sessions\session_handshake.hpp">
<Filter>include\bitcoin\server\sessions</Filter>
</ClInclude>
Expand Down
2 changes: 1 addition & 1 deletion console/executor_runner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void executor::subscribe_connect()
{
node_->subscribe_connect
(
[&](const code&, const channel::ptr&)
[&](const code&, const network::channel::ptr&)
{
log_.write(levels::verbose) <<
"{in:" << node_->inbound_channel_count() << "}"
Expand Down
2 changes: 2 additions & 0 deletions include/bitcoin/server.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <bitcoin/server/server_node.hpp>
#include <bitcoin/server/settings.hpp>
#include <bitcoin/server/version.hpp>
#include <bitcoin/server/channels/channel.hpp>
#include <bitcoin/server/channels/channel_electrum.hpp>
#include <bitcoin/server/channels/channel_http.hpp>
#include <bitcoin/server/channels/channel_stratum_v1.hpp>
Expand Down Expand Up @@ -55,6 +56,7 @@
#include <bitcoin/server/protocols/protocol_stratum_v1.hpp>
#include <bitcoin/server/protocols/protocol_stratum_v2.hpp>
#include <bitcoin/server/protocols/protocols.hpp>
#include <bitcoin/server/sessions/session.hpp>
#include <bitcoin/server/sessions/session_handshake.hpp>
#include <bitcoin/server/sessions/session_server.hpp>
#include <bitcoin/server/sessions/sessions.hpp>
Expand Down
41 changes: 41 additions & 0 deletions include/bitcoin/server/channels/channel.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
* 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 <http://www.gnu.org/licenses/>.
*/
#ifndef LIBBITCOIN_SERVER_CHANNELS_CHANNEL_HPP
#define LIBBITCOIN_SERVER_CHANNELS_CHANNEL_HPP

#include <memory>
#include <bitcoin/server/define.hpp>

namespace libbitcoin {
namespace server {

/// Intermediate base class for future server injection.
class BCS_API channel
: public node::channel
{
public:
typedef std::shared_ptr<channel> ptr;
using base = node::channel;
using base::channel;
};

} // namespace server
} // namespace libbitcoin

#endif
5 changes: 3 additions & 2 deletions include/bitcoin/server/channels/channel_electrum.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#define LIBBITCOIN_SERVER_CHANNELS_CHANNEL_ELECTRUM_HPP

#include <memory>
#include <bitcoin/server/channels/channel.hpp>
#include <bitcoin/server/configuration.hpp>
#include <bitcoin/server/define.hpp>
#include <bitcoin/server/interfaces/interfaces.hpp>
Expand All @@ -31,7 +32,7 @@ namespace server {
// TODO: strip extraneous args before electrum version dispatch.
/// Channel for electrum channels (non-http json-rpc).
class BCS_API channel_electrum
: public node::channel,
: public server::channel,
public network::channel_rpc<interface::electrum>,
protected network::tracker<channel_electrum>
{
Expand All @@ -43,7 +44,7 @@ class BCS_API channel_electrum
inline channel_electrum(const network::logger& log,
const network::socket::ptr& socket, uint64_t identifier,
const node::configuration& config, const options_t& options) NOEXCEPT
: node::channel(log, socket, identifier, config),
: server::channel(log, socket, identifier, config),
network::channel_rpc<interface::electrum>(log, socket, identifier,
config.network, options),
network::tracker<channel_electrum>(log)
Expand Down
5 changes: 3 additions & 2 deletions include/bitcoin/server/channels/channel_http.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@
#define LIBBITCOIN_SERVER_CHANNELS_CHANNEL_HTTP_HPP

#include <memory>
#include <bitcoin/server/channels/channel.hpp>
#include <bitcoin/server/configuration.hpp>
#include <bitcoin/server/define.hpp>

namespace libbitcoin {
namespace server {

class BCS_API channel_http
: public node::channel,
: public server::channel,
public network::channel_http,
protected network::tracker<channel_http>
{
Expand All @@ -37,7 +38,7 @@ class BCS_API channel_http
inline channel_http(const network::logger& log,
const network::socket::ptr& socket, uint64_t identifier,
const node::configuration& config, const options_t& options) NOEXCEPT
: node::channel(log, socket, identifier, config),
: server::channel(log, socket, identifier, config),
network::channel_http(log, socket, identifier, config.network, options),
network::tracker<channel_http>(log)
{
Expand Down
5 changes: 3 additions & 2 deletions include/bitcoin/server/channels/channel_stratum_v1.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#define LIBBITCOIN_SERVER_CHANNELS_CHANNEL_STRATUM_V1_HPP

#include <memory>
#include <bitcoin/server/channels/channel.hpp>
#include <bitcoin/server/configuration.hpp>
#include <bitcoin/server/define.hpp>
#include <bitcoin/server/interfaces/interfaces.hpp>
Expand All @@ -29,7 +30,7 @@ namespace server {

/// Channel for stratum v1 channels (non-http json-rpc).
class BCS_API channel_stratum_v1
: public node::channel,
: public server::channel,
public network::channel_rpc<interface::stratum_v1>,
protected network::tracker<channel_stratum_v1>
{
Expand All @@ -41,7 +42,7 @@ class BCS_API channel_stratum_v1
inline channel_stratum_v1(const network::logger& log,
const network::socket::ptr& socket, uint64_t identifier,
const node::configuration& config, const options_t& options) NOEXCEPT
: node::channel(log, socket, identifier, config),
: server::channel(log, socket, identifier, config),
network::channel_rpc<interface::stratum_v1>(log, socket, identifier,
config.network, options),
network::tracker<channel_stratum_v1>(log)
Expand Down
5 changes: 3 additions & 2 deletions include/bitcoin/server/channels/channel_stratum_v2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#define LIBBITCOIN_SERVER_CHANNELS_CHANNEL_STRATUM_V2_HPP

#include <memory>
#include <bitcoin/server/channels/channel.hpp>
#include <bitcoin/server/configuration.hpp>
#include <bitcoin/server/define.hpp>

Expand All @@ -28,7 +29,7 @@ namespace server {

/// Channel for stratum v2 (custom protocol, not implemented).
class BCS_API channel_stratum_v2
: public node::channel,
: public server::channel,
public network::channel,
protected network::tracker<channel_stratum_v2>
{
Expand All @@ -38,7 +39,7 @@ class BCS_API channel_stratum_v2
inline channel_stratum_v2(const network::logger& log,
const network::socket::ptr& socket, uint64_t identifier,
const node::configuration& config, const options_t& options) NOEXCEPT
: node::channel(log, socket, identifier, config),
: server::channel(log, socket, identifier, config),
network::channel(log, socket, identifier, config.network, options),
network::tracker<channel_stratum_v2>(log)
{
Expand Down
5 changes: 3 additions & 2 deletions include/bitcoin/server/channels/channel_ws.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@
#define LIBBITCOIN_SERVER_CHANNELS_CHANNEL_WS_HPP

#include <memory>
#include <bitcoin/server/channels/channel.hpp>
#include <bitcoin/server/configuration.hpp>
#include <bitcoin/server/define.hpp>

namespace libbitcoin {
namespace server {

class BCS_API channel_ws
: public node::channel,
: public server::channel,
public network::channel_ws,
protected network::tracker<channel_ws>
{
Expand Down Expand Up @@ -72,7 +73,7 @@ class BCS_API channel_ws
inline channel_ws(const network::logger& log,
const network::socket::ptr& socket, uint64_t identifier,
const node::configuration& config, const options_t& options) NOEXCEPT
: node::channel(log, socket, identifier, config),
: server::channel(log, socket, identifier, config),
network::channel_ws(log, socket, identifier, config.network, options),
network::tracker<channel_ws>(log)
{
Expand Down
30 changes: 30 additions & 0 deletions include/bitcoin/server/channels/channels.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#ifndef LIBBITCOIN_SERVER_CHANNELS_CHANNELS_HPP
#define LIBBITCOIN_SERVER_CHANNELS_CHANNELS_HPP

#include <bitcoin/server/channels/channel.hpp>
#include <bitcoin/server/channels/channel_electrum.hpp>
#include <bitcoin/server/channels/channel_http.hpp>
#include <bitcoin/server/channels/channel_stratum_v1.hpp>
Expand All @@ -27,3 +28,32 @@

#endif

/*

Network provides the base for all channels as rpc, http, peer. Websocket and
html are not fully independent subclasses (operate within http).

network::channel
├── [server::channel_stratum_v2]
├── channel_rpc<Interface>
│ └── [server::channel_stratum_v1]
│ └── [server::channel_electrum]
├── channel_http
│ ├── [server::channel_http]
│ └── channel_ws
│ └── [server::channel_ws]
└── channel_peer
└── [node::channel_peer]

node::channel
├── [server::channel]
└── channel_peer → network::channel_peer

server::channel → node::channel
├── channel_stratum_v2 → network::channel
├── channel_stratum_v1 → network::channel_rpc<interface::stratum_v1>
├── channel_electrum → network::channel_rpc<interface::electrum>
├── channel_http → network::channel_http
└── channel_ws → network::channel_ws

*/
3 changes: 3 additions & 0 deletions include/bitcoin/server/define.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
#define BCS_INTERNAL BC_HELPER_DLL_LOCAL
#endif

/// Prevent bogus vc++ warnings on protocol.
BC_DISABLE_WARNING(DIAMOND_INHERITANCE)

/// Augment limited xcode placeholder defines (10 vs. common 20).
/// ---------------------------------------------------------------------------
#if defined (HAVE_XCODE)
Expand Down
64 changes: 64 additions & 0 deletions include/bitcoin/server/protocols/protocols.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,67 @@
#include <bitcoin/server/protocols/protocol_admin.hpp>

#endif

/*

Network provides the base for all protocols as rpc, http, peer. However node
and server do not inherit directly from network. Server extends node, but
neither inherit from network until a subclass is defined (rpc, http, peer).
Since stratum_v2 is just a stub it doesn't yet have its own subclass. Websocket
and html are not independent subclasses (operate within http).

network::protocol
├── [server:protocol_stratum_v2]
├── protocol_rpc<Channel>
│ └── [server::protocol_rpc<server::channel_stratum_v1>]
│ └── [server::protocol_rpc<server::channel_electrum>]
├── protocol_http
│ ├── [server::protocol_bitcoind_rpc]
│ └── protocol_ws
│ └── [server::protocol_html]
└── protocol_peer
├── [node::protocol_peer]
├── protocol_alert_311
├── protocol_reject_70002
├── protocol_seed_209
├── protocol_address_in_209
├── protocol_address_out_209
├── protocol_ping_106
│ └── protocol_ping_60001
└── protocol_version_106
└── protocol_version_70001
└── protocol_version_70002
└── protocol_version_70016

node::protocol
├── [server::protocol]
└── protocol_peer → network::protocol_peer
├── protocol_observer
├── protocol_filter_out_70015
├── protocol_block_in_106
├── protocol_performer
│ └── protocol_block_in_31800
├── protocol_block_out_106
│ └── protocol_block_out_70012
├── protocol_header_in_31800
│ └── protocol_header_in_70012
├── protocol_header_out_31800
│ └── protocol_header_out_70012
├── protocol_transaction_in_106
└── protocol_transaction_out_106

server::protocol → node::protocol
├── protocol_stratum_v2 → network::protocol
├── protocol_rpc<channel_stratum_v1> → network::protocol_rpc<channel_stratum_v1>
│ └── protocol_stratum_v1
├── protocol_rpc<channel_electrum> → network::protocol_rpc<channel_electrum>
│ ├── protocol_electrum
│ └── protocol_electrum_version
└── protocol_http
├── protocol_html → network::protocol_ws
│ ├── protocol_admin
│ └── protocol_native
└── protocol_bitcoind_rpc → network::protocol_http
└── protocol_bitcoind_rest

*/
Loading
Loading