diff --git a/Makefile.am b/Makefile.am
index d5a443a23..41a5eb6d2 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -75,8 +75,7 @@ src_libbitcoin_node_la_SOURCES = \
src/sessions/session.cpp \
src/sessions/session_inbound.cpp \
src/sessions/session_manual.cpp \
- src/sessions/session_outbound.cpp \
- src/sessions/session_tcp.cpp
+ src/sessions/session_outbound.cpp
# local: test/libbitcoin-node-test
#------------------------------------------------------------------------------
@@ -243,7 +242,6 @@ include_bitcoin_node_sessions_HEADERS = \
include/bitcoin/node/sessions/session_outbound.hpp \
include/bitcoin/node/sessions/session_peer.hpp \
include/bitcoin/node/sessions/session_server.hpp \
- include/bitcoin/node/sessions/session_tcp.hpp \
include/bitcoin/node/sessions/sessions.hpp
# files => ${bash_completiondir}
diff --git a/builds/cmake/CMakeLists.txt b/builds/cmake/CMakeLists.txt
index 994371cec..56c2ea0d8 100644
--- a/builds/cmake/CMakeLists.txt
+++ b/builds/cmake/CMakeLists.txt
@@ -287,8 +287,7 @@ add_library( ${CANONICAL_LIB_NAME}
"../../src/sessions/session.cpp"
"../../src/sessions/session_inbound.cpp"
"../../src/sessions/session_manual.cpp"
- "../../src/sessions/session_outbound.cpp"
- "../../src/sessions/session_tcp.cpp" )
+ "../../src/sessions/session_outbound.cpp" )
# ${CANONICAL_LIB_NAME} project specific include directory normalization for build.
#------------------------------------------------------------------------------
diff --git a/builds/msvc/vs2022/libbitcoin-node/libbitcoin-node.vcxproj b/builds/msvc/vs2022/libbitcoin-node/libbitcoin-node.vcxproj
index 893eff0df..129082336 100644
--- a/builds/msvc/vs2022/libbitcoin-node/libbitcoin-node.vcxproj
+++ b/builds/msvc/vs2022/libbitcoin-node/libbitcoin-node.vcxproj
@@ -161,7 +161,6 @@
-
@@ -228,7 +227,6 @@
-
diff --git a/builds/msvc/vs2022/libbitcoin-node/libbitcoin-node.vcxproj.filters b/builds/msvc/vs2022/libbitcoin-node/libbitcoin-node.vcxproj.filters
index 94a9284d7..225490d1f 100644
--- a/builds/msvc/vs2022/libbitcoin-node/libbitcoin-node.vcxproj.filters
+++ b/builds/msvc/vs2022/libbitcoin-node/libbitcoin-node.vcxproj.filters
@@ -180,9 +180,6 @@
src\sessions
-
- src\sessions
-
src
@@ -377,9 +374,6 @@
include\bitcoin\node\sessions
-
- include\bitcoin\node\sessions
-
include\bitcoin\node\sessions
diff --git a/include/bitcoin/node.hpp b/include/bitcoin/node.hpp
index 735648e6c..aadba7885 100644
--- a/include/bitcoin/node.hpp
+++ b/include/bitcoin/node.hpp
@@ -80,7 +80,6 @@
#include
#include
#include
-#include
#include
#endif
diff --git a/include/bitcoin/node/channels/channel_http.hpp b/include/bitcoin/node/channels/channel_http.hpp
index 1b0c6e5c1..512c59c0f 100644
--- a/include/bitcoin/node/channels/channel_http.hpp
+++ b/include/bitcoin/node/channels/channel_http.hpp
@@ -27,10 +27,9 @@
namespace libbitcoin {
namespace node {
-/// Abstract base HTTP channel state for the node.
class BCN_API channel_http
- : public network::channel_http,
- public node::channel
+ : public node::channel,
+ public network::channel_http
{
public:
typedef std::shared_ptr ptr;
@@ -38,8 +37,8 @@ class BCN_API channel_http
channel_http(const network::logger& log,
const network::socket::ptr& socket, uint64_t identifier,
const node::configuration& config, const options_t& options) NOEXCEPT
- : network::channel_http(log, socket, identifier, config.network, options),
- node::channel(log, socket, identifier, config)
+ : node::channel(log, socket, identifier, config),
+ network::channel_http(log, socket, identifier, config.network, options)
{
}
};
diff --git a/include/bitcoin/node/channels/channel_peer.hpp b/include/bitcoin/node/channels/channel_peer.hpp
index 4972df41c..967604bf6 100644
--- a/include/bitcoin/node/channels/channel_peer.hpp
+++ b/include/bitcoin/node/channels/channel_peer.hpp
@@ -29,8 +29,8 @@ namespace node {
/// Abstract base peer channel state for the node.
class BCN_API channel_peer
- : public network::channel_peer,
- public node::channel
+ : public node::channel,
+ public network::channel_peer
{
public:
typedef std::shared_ptr ptr;
@@ -38,9 +38,9 @@ class BCN_API channel_peer
channel_peer(network::memory& allocator, const network::logger& log,
const network::socket::ptr& socket, uint64_t identifier,
const node::configuration& config, const options_t& options) NOEXCEPT
- : network::channel_peer(allocator, log, socket, identifier,
+ : node::channel(log, socket, identifier, config),
+ network::channel_peer(allocator, log, socket, identifier,
config.network, options),
- node::channel(log, socket, identifier, config),
announced_(config.node.announcement_cache)
{
}
diff --git a/include/bitcoin/node/channels/channel_tcp.hpp b/include/bitcoin/node/channels/channel_tcp.hpp
index 265885709..9af3c5685 100644
--- a/include/bitcoin/node/channels/channel_tcp.hpp
+++ b/include/bitcoin/node/channels/channel_tcp.hpp
@@ -29,8 +29,8 @@ namespace node {
/// Abstract base TCP channel state for the node.
class BCN_API channel_tcp
- : public network::channel_tcp,
- public node::channel
+ : public node::channel,
+ public network::channel
{
public:
typedef std::shared_ptr ptr;
@@ -38,8 +38,8 @@ class BCN_API channel_tcp
channel_tcp(const network::logger& log, const network::socket::ptr& socket,
uint64_t identifier, const node::configuration& config,
const options_t& options) NOEXCEPT
- : network::channel_tcp(log, socket, identifier, config.network, options),
- node::channel(log, socket, identifier, config)
+ : node::channel(log, socket, identifier, config),
+ network::channel(log, socket, identifier, config.network, options)
{
}
};
diff --git a/include/bitcoin/node/channels/channel_ws.hpp b/include/bitcoin/node/channels/channel_ws.hpp
index 0c8b006de..17943369c 100644
--- a/include/bitcoin/node/channels/channel_ws.hpp
+++ b/include/bitcoin/node/channels/channel_ws.hpp
@@ -27,11 +27,9 @@
namespace libbitcoin {
namespace node {
-/// Abstract base websocket channel state for the node.
-/// Does not inherit node::channel_http but does inherit network::channel_http.
class BCN_API channel_ws
- : public network::channel_ws,
- public node::channel
+ : public node::channel,
+ public network::channel_ws
{
public:
typedef std::shared_ptr ptr;
@@ -39,8 +37,8 @@ class BCN_API channel_ws
channel_ws(const network::logger& log, const network::socket::ptr& socket,
uint64_t identifier, const node::configuration& config,
const options_t& options) NOEXCEPT
- : network::channel_ws(log, socket, identifier, config.network, options),
- node::channel(log, socket, identifier, config)
+ : node::channel(log, socket, identifier, config),
+ network::channel_ws(log, socket, identifier, config.network, options)
{
}
};
diff --git a/include/bitcoin/node/protocols/protocol_html.hpp b/include/bitcoin/node/protocols/protocol_html.hpp
index 50d562165..948b8ca3d 100644
--- a/include/bitcoin/node/protocols/protocol_html.hpp
+++ b/include/bitcoin/node/protocols/protocol_html.hpp
@@ -29,8 +29,8 @@ namespace node {
/// Abstract base for HTML protocols, thread safe.
class BCN_API protocol_html
- : public network::protocol_http,
- public node::protocol
+ : public node::protocol,
+ public network::protocol_http
{
public:
/// http channel, but html settings.
@@ -41,9 +41,9 @@ class BCN_API protocol_html
protocol_html(const auto& session,
const network::channel::ptr& channel,
const options_t& options) NOEXCEPT
- : network::protocol_http(session, channel, options),
- options_(options),
- node::protocol(session, channel)
+ : node::protocol(session, channel),
+ network::protocol_http(session, channel, options),
+ options_(options)
{
}
diff --git a/include/bitcoin/node/protocols/protocol_http.hpp b/include/bitcoin/node/protocols/protocol_http.hpp
index fe3ca2d9a..079c582cf 100644
--- a/include/bitcoin/node/protocols/protocol_http.hpp
+++ b/include/bitcoin/node/protocols/protocol_http.hpp
@@ -32,8 +32,8 @@ namespace node {
/// Abstract base for HTTP protocols, thread safe.
class BCN_API protocol_http
- : public network::protocol_http,
- public node::protocol
+ : public node::protocol,
+ public network::protocol_http
{
public:
// Replace base class channel_t (network::channel_http).
@@ -43,8 +43,8 @@ class BCN_API protocol_http
protocol_http(const auto& session,
const network::channel::ptr& channel,
const options_t& options) NOEXCEPT
- : network::protocol_http(session, channel, options),
- node::protocol(session, channel),
+ : node::protocol(session, channel),
+ network::protocol_http(session, channel, options),
channel_(std::static_pointer_cast(channel)),
session_(session)
{
diff --git a/include/bitcoin/node/protocols/protocol_peer.hpp b/include/bitcoin/node/protocols/protocol_peer.hpp
index 433b53ae7..b56f821c2 100644
--- a/include/bitcoin/node/protocols/protocol_peer.hpp
+++ b/include/bitcoin/node/protocols/protocol_peer.hpp
@@ -32,8 +32,8 @@ namespace node {
/// Abstract base for node peer protocols, thread safe.
class BCN_API protocol_peer
- : public network::protocol_peer,
- public node::protocol
+ : public node::protocol,
+ public network::protocol_peer
{
public:
// Replace base class channel_t (network::channel_peer).
@@ -46,8 +46,8 @@ class BCN_API protocol_peer
protocol_peer(const auto& session,
const network::channel::ptr& channel) NOEXCEPT
- : network::protocol_peer(session, channel),
- node::protocol(session, channel),
+ : node::protocol(session, channel),
+ network::protocol_peer(session, channel),
channel_(std::static_pointer_cast(channel)),
session_(session)
{
diff --git a/include/bitcoin/node/protocols/protocol_tcp.hpp b/include/bitcoin/node/protocols/protocol_tcp.hpp
index 5df824894..877b3c50f 100644
--- a/include/bitcoin/node/protocols/protocol_tcp.hpp
+++ b/include/bitcoin/node/protocols/protocol_tcp.hpp
@@ -32,19 +32,18 @@ namespace node {
/// Abstract base for TCP protocols, thread safe.
class BCN_API protocol_tcp
- : public network::protocol_tcp,
- public node::protocol
+ : public node::protocol,
+ public network::protocol
{
public:
- // Replace base class channel_t (network::channel_tcp).
+ // Replace base class channel_t (network::channel).
using channel_t = node::channel_tcp;
protected:
protocol_tcp(const auto& session,
- const network::channel::ptr& channel,
- const options_t& options) NOEXCEPT
- : network::protocol_tcp(session, channel, options),
- node::protocol(session, channel),
+ const network::channel::ptr& channel, const options_t&) NOEXCEPT
+ : node::protocol(session, channel),
+ network::protocol(session, channel),
channel_(std::static_pointer_cast(channel)),
session_(session)
{
diff --git a/include/bitcoin/node/protocols/protocol_ws.hpp b/include/bitcoin/node/protocols/protocol_ws.hpp
index fdfe39c46..24e93fb99 100644
--- a/include/bitcoin/node/protocols/protocol_ws.hpp
+++ b/include/bitcoin/node/protocols/protocol_ws.hpp
@@ -29,8 +29,8 @@ namespace node {
// TODO: make this an intermediate base class for websocket.
// TODO: and then create a distinct concrete class for deployment.
class BCN_API protocol_ws
- : public network::protocol_ws,
- public node::protocol,
+ : public node::protocol,
+ public network::protocol_ws,
protected network::tracker
{
public:
@@ -42,8 +42,8 @@ class BCN_API protocol_ws
protocol_ws(const auto& session,
const network::channel::ptr& channel,
const options_t& options) NOEXCEPT
- : network::protocol_ws(session, channel, options),
- node::protocol(session, channel),
+ : node::protocol(session, channel),
+ network::protocol_ws(session, channel, options),
network::tracker(session->log)
{
}
diff --git a/include/bitcoin/node/sessions/session.hpp b/include/bitcoin/node/sessions/session.hpp
index 5343d544c..5198e4249 100644
--- a/include/bitcoin/node/sessions/session.hpp
+++ b/include/bitcoin/node/sessions/session.hpp
@@ -28,7 +28,6 @@ namespace node {
class full_node;
/// Common session context, presumes will be joined with network::session.
-/// This could be templatized on the sibling, but there only one implemented.
class BCN_API session
{
public:
diff --git a/include/bitcoin/node/sessions/session_peer.hpp b/include/bitcoin/node/sessions/session_peer.hpp
index f8401c624..8dac21a72 100644
--- a/include/bitcoin/node/sessions/session_peer.hpp
+++ b/include/bitcoin/node/sessions/session_peer.hpp
@@ -32,21 +32,21 @@ namespace node {
/// Template for network::session derivation with node::session.
/// node::session does not derive from network::session (siblings).
/// This avoids the diamond inheritance problem between network/node.
-template
+template
class session_peer
- : public Session,
- public node::session
+ : public node::session,
+ public NetworkSession
{
public:
- typedef std::shared_ptr> ptr;
- using options_t = typename Session::options_t;
+ typedef std::shared_ptr> ptr;
+ using options_t = typename NetworkSession::options_t;
using channel_t = node::channel_peer;
/// Construct an instance.
template
session_peer(Node& node, Args&&... args) NOEXCEPT
- : Session(node, std::forward(args)...),
- node::session(node)
+ : node::session(node),
+ NetworkSession(node, std::forward(args)...)
{
}
@@ -79,7 +79,7 @@ class session_peer
peer->set_start_height(top);
// Attach and execute appropriate version protocol.
- Session::attach_handshake(channel, std::move(handler));
+ NetworkSession::attach_handshake(channel, std::move(handler));
}
void attach_protocols(const channel_ptr& channel) NOEXCEPT override
@@ -90,7 +90,7 @@ class session_peer
using namespace system;
using namespace network;
using namespace messages::peer;
- using base = session_peer;
+ using base = session_peer;
const auto self = this->template shared_from_base();
const auto relay = this->config().network.enable_relay;
@@ -108,7 +108,7 @@ class session_peer
));
// Attach appropriate alert, reject, ping, and/or address protocols.
- Session::attach_protocols(channel);
+ NetworkSession::attach_protocols(channel);
// Channel suspensions.
channel->attach(self)->start();
diff --git a/include/bitcoin/node/sessions/session_server.hpp b/include/bitcoin/node/sessions/session_server.hpp
index ec4f6cd0e..61e0645bc 100644
--- a/include/bitcoin/node/sessions/session_server.hpp
+++ b/include/bitcoin/node/sessions/session_server.hpp
@@ -22,25 +22,25 @@
#include
#include
#include
-#include
+#include
namespace libbitcoin {
namespace node {
-class full_node;
-
-// make_shared<>
BC_PUSH_WARNING(NO_THROW_IN_NOEXCEPT)
+class full_node;
+
/// Declare a concrete instance of this type for client-server protocols built
-/// on tcp/ip. session_tcp processing performs all connection management and
+/// on tcp/ip. session_base processing performs all connection management and
/// session tracking. This includes start/stop/disable/enable/black/whitelist.
/// Protocol must declare options_t and channel_t. This protocol is constructed
/// and attached to a constructed instance of channel_t. The protocol construct
/// and attachment can be overridden and/or augmented with other protocols.
template
class session_server
- : public session_tcp,
+ : public network::session_server,
+ public node::session,
protected network::tracker>
{
public:
@@ -51,12 +51,12 @@ class session_server
using channel_t = typename Protocol::channel_t;
/// Construct an instance (network should be started).
- template
- session_server(full_node& node, uint64_t identifier, const options_t& options,
- Args&&... args) NOEXCEPT
- : session_tcp(node, identifier, options, std::forward(args)...),
- options_(options),
- network::tracker>(node)
+ inline session_server(full_node& node, uint64_t identifier,
+ const options_t& options) NOEXCEPT
+ : network::session_server((network::net&)node, identifier, options),
+ node::session(node),
+ network::tracker>(node),
+ options_(options)
{
}
@@ -64,10 +64,18 @@ class session_server
using socket_ptr = network::socket::ptr;
using channel_ptr = network::channel::ptr;
+ /// Inbound connection attempts are dropped unless confirmed is current.
+ /// Used instead of suspension because that has independent start/stop.
+ inline bool enabled() const NOEXCEPT override
+ {
+ return !config().node.delay_inbound || is_recent();
+ }
+
/// Override to construct channel. This allows the implementation to pass
/// other values to protocol construction and/or select the desired channel
/// based on available factors (e.g. a distinct protocol version).
- channel_ptr create_channel(const socket_ptr& socket) NOEXCEPT override
+ inline channel_ptr create_channel(
+ const socket_ptr& socket) NOEXCEPT override
{
BC_ASSERT(stranded());
@@ -82,25 +90,25 @@ class session_server
/// is used to implement TLS and WebSocket upgrade from http (for example).
/// Handshake protocol(s) must invoke handler one time at completion.
/// Use std::dynamic_pointer_cast(channel) to obtain channel_t.
- void attach_handshake(const channel_ptr& channel,
+ inline void attach_handshake(const channel_ptr& channel,
network::result_handler&& handler) NOEXCEPT override
{
BC_ASSERT(channel->stranded());
BC_ASSERT(channel->paused());
- session_tcp::attach_handshake(channel, std::move(handler));
+ network::session_server::attach_handshake(channel, std::move(handler));
}
/// Overridden to set channel protocols. This allows the implementation to
/// pass other values to protocol construction and/or select the desired
/// protocol based on available factors (e.g. a distinct protocol version).
/// Use std::dynamic_pointer_cast(channel) to obtain channel_t.
- void attach_protocols(const channel_ptr& channel) NOEXCEPT override
+ inline void attach_protocols(const channel_ptr& channel) NOEXCEPT override
{
BC_ASSERT(channel->stranded());
BC_ASSERT(channel->paused());
- const auto self = shared_from_base();
+ const auto self = shared_from_base>();
channel->attach(self, options_)->start();
}
diff --git a/include/bitcoin/node/sessions/session_tcp.hpp b/include/bitcoin/node/sessions/session_tcp.hpp
deleted file mode 100644
index f28ecf4cd..000000000
--- a/include/bitcoin/node/sessions/session_tcp.hpp
+++ /dev/null
@@ -1,55 +0,0 @@
-/**
- * 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 .
- */
-#ifndef LIBBITCOIN_NODE_SESSIONS_SESSION_TCP_HPP
-#define LIBBITCOIN_NODE_SESSIONS_SESSION_TCP_HPP
-
-#include
-#include
-#include
-
-namespace libbitcoin {
-namespace node {
-
-class full_node;
-
-class BCN_API session_tcp
- : public network::session_tcp,
- public node::session
-{
-public:
- typedef std::shared_ptr ptr;
- using options_t = network::session_tcp::options_t;
- using channel_t = node::channel_tcp;
-
- // (network::net&) cast due to full_node forward ref (inheritance hidden).
- session_tcp(full_node& node, uint64_t identifier,
- const options_t& options) NOEXCEPT
- : network::session_tcp((network::net&)node, identifier, options),
- node::session(node)
- {
- }
-
-protected:
- bool enabled() const NOEXCEPT override;
-};
-
-} // namespace node
-} // namespace libbitcoin
-
-#endif
diff --git a/include/bitcoin/node/sessions/sessions.hpp b/include/bitcoin/node/sessions/sessions.hpp
index 3e265ccca..36bcb3ceb 100644
--- a/include/bitcoin/node/sessions/sessions.hpp
+++ b/include/bitcoin/node/sessions/sessions.hpp
@@ -25,12 +25,13 @@
#include
#include
#include
-#include
+
+#include
namespace libbitcoin {
namespace node {
-// Alias server sessions derived from session_tcp.
+/// Alias server sessions, all derived from node::session.
using session_web = session_server;
using session_explore = session_server;
using session_websocket = session_server;
diff --git a/src/sessions/session_tcp.cpp b/src/sessions/session_tcp.cpp
deleted file mode 100644
index ff00f71c6..000000000
--- a/src/sessions/session_tcp.cpp
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * 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 .
- */
-#include
-
-#include
-
-namespace libbitcoin {
-namespace node {
-
-// Inbound connection attempts are dropped unless confirmed chain is current.
-// Used instead of suspension because suspension has independent start/stop.
-bool session_tcp::enabled() const NOEXCEPT
-{
- return !config().node.delay_inbound || is_recent();
-}
-
-} // namespace node
-} // namespace libbitcoin