2020#define LIBBITCOIN_NODE_SESSIONS_ATTACH_HPP
2121
2222#include < memory>
23+ #include < utility>
2324#include < bitcoin/network.hpp>
2425#include < bitcoin/node/define.hpp>
2526#include < bitcoin/node/protocols/protocols.hpp>
@@ -30,7 +31,7 @@ namespace node {
3031
3132class full_node ;
3233
33- // / Session base class template for protocol attachment.
34+ // / Session base class template for network session attachment.
3435// / node::session does not derive from network::session (siblings).
3536// / This avoids the diamond inheritance problem between network/node.
3637// / Protocol contructors are templatized on Session, obtaining session.
@@ -39,8 +40,10 @@ class attach
3940 : public Session, public node::session
4041{
4142public:
42- attach (full_node& node, uint64_t identifier) NOEXCEPT
43- : Session(node, identifier), session(node)
43+ template <typename ... Args>
44+ attach (full_node& node, uint64_t identifier, Args&&... args) NOEXCEPT
45+ : Session(node, identifier, std::forward<Args>(args)...),
46+ node::session (node)
4447 {
4548 }
4649
@@ -56,21 +59,22 @@ class attach
5659 Session::attach_handshake (channel, std::move (handler));
5760 }
5861
59- void attach_protocols (const network::channel::ptr& channel) NOEXCEPT override
62+ void attach_protocols (
63+ const network::channel::ptr& channel) NOEXCEPT override
6064 {
6165 using namespace system ;
6266 using namespace network ::messages::peer;
63- const auto relay = config ().network .enable_relay ;
64- const auto delay = config ().node .delay_inbound ;
65- const auto headers = config ().node .headers_first ;
67+ const auto relay = this -> config ().network .enable_relay ;
68+ const auto delay = this -> config ().node .delay_inbound ;
69+ const auto headers = this -> config ().node .headers_first ;
6670 const auto node_network = to_bool (bit_and<uint64_t >
6771 (
68- config ().network .services_maximum ,
72+ this -> config ().network .services_maximum ,
6973 network::messages::peer::service::node_network
7074 ));
7175 const auto node_client_filters = to_bool (bit_and<uint64_t >
7276 (
73- config ().network .services_maximum ,
77+ this -> config ().network .services_maximum ,
7478 network::messages::peer::service::node_client_filters
7579 ));
7680
@@ -158,12 +162,12 @@ class attach
158162 }
159163 }
160164
161- network::channel::ptr create_channel (const network::socket::ptr& socket) NOEXCEPT override
165+ network::channel::ptr create_channel (
166+ const network::socket::ptr& socket) NOEXCEPT override
162167 {
163168 return std::static_pointer_cast<network::channel>(
164- std::make_shared<node::channel_peer>(node::session::get_memory (),
165- network::session::log, socket, node::session::config (),
166- network::session::create_key ()));
169+ std::make_shared<node::channel_peer>(this ->get_memory (), this ->log ,
170+ socket, this ->config (), this ->create_key ()));
167171 }
168172};
169173
0 commit comments