mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-25 10:43:19 -03:00
net: add CNodeOptions for optional CNode constructor params
This commit is contained in:
parent
52dcb1d2a3
commit
9dccc3328e
2 changed files with 9 additions and 4 deletions
|
@ -556,7 +556,7 @@ CNode* CConnman::ConnectNode(CAddress addrConnect, const char *pszDest, bool fCo
|
|||
pszDest ? pszDest : "",
|
||||
conn_type,
|
||||
/*inbound_onion=*/false,
|
||||
std::move(i2p_transient_session));
|
||||
CNodeOptions{ .i2p_sam_session = std::move(i2p_transient_session) });
|
||||
pnode->AddRef();
|
||||
|
||||
// We're making a new connection, harvest entropy from the time (and our peer count)
|
||||
|
@ -2722,7 +2722,7 @@ CNode::CNode(NodeId idIn,
|
|||
const std::string& addrNameIn,
|
||||
ConnectionType conn_type_in,
|
||||
bool inbound_onion,
|
||||
std::unique_ptr<i2p::sam::Session>&& i2p_sam_session)
|
||||
CNodeOptions&& node_opts)
|
||||
: m_deserializer{std::make_unique<V1TransportDeserializer>(V1TransportDeserializer(Params(), idIn, SER_NETWORK, INIT_PROTO_VERSION))},
|
||||
m_serializer{std::make_unique<V1TransportSerializer>(V1TransportSerializer())},
|
||||
m_sock{sock},
|
||||
|
@ -2735,7 +2735,7 @@ CNode::CNode(NodeId idIn,
|
|||
id{idIn},
|
||||
nLocalHostNonce{nLocalHostNonceIn},
|
||||
m_conn_type{conn_type_in},
|
||||
m_i2p_sam_session{std::move(i2p_sam_session)}
|
||||
m_i2p_sam_session{std::move(node_opts.i2p_sam_session)}
|
||||
{
|
||||
if (inbound_onion) assert(conn_type_in == ConnectionType::INBOUND);
|
||||
|
||||
|
|
|
@ -334,6 +334,11 @@ public:
|
|||
void prepareForTransport(CSerializedNetMsg& msg, std::vector<unsigned char>& header) const override;
|
||||
};
|
||||
|
||||
struct CNodeOptions
|
||||
{
|
||||
std::unique_ptr<i2p::sam::Session> i2p_sam_session = nullptr;
|
||||
};
|
||||
|
||||
/** Information about a peer */
|
||||
class CNode
|
||||
{
|
||||
|
@ -522,7 +527,7 @@ public:
|
|||
const std::string& addrNameIn,
|
||||
ConnectionType conn_type_in,
|
||||
bool inbound_onion,
|
||||
std::unique_ptr<i2p::sam::Session>&& i2p_sam_session = nullptr);
|
||||
CNodeOptions&& node_opts = {});
|
||||
CNode(const CNode&) = delete;
|
||||
CNode& operator=(const CNode&) = delete;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue