Skip to content

Commit 9dccc33

Browse files
committed
net: add CNodeOptions for optional CNode constructor params
1 parent 52dcb1d commit 9dccc33

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/net.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ CNode* CConnman::ConnectNode(CAddress addrConnect, const char *pszDest, bool fCo
556556
pszDest ? pszDest : "",
557557
conn_type,
558558
/*inbound_onion=*/false,
559-
std::move(i2p_transient_session));
559+
CNodeOptions{ .i2p_sam_session = std::move(i2p_transient_session) });
560560
pnode->AddRef();
561561

562562
// We're making a new connection, harvest entropy from the time (and our peer count)
@@ -2722,7 +2722,7 @@ CNode::CNode(NodeId idIn,
27222722
const std::string& addrNameIn,
27232723
ConnectionType conn_type_in,
27242724
bool inbound_onion,
2725-
std::unique_ptr<i2p::sam::Session>&& i2p_sam_session)
2725+
CNodeOptions&& node_opts)
27262726
: m_deserializer{std::make_unique<V1TransportDeserializer>(V1TransportDeserializer(Params(), idIn, SER_NETWORK, INIT_PROTO_VERSION))},
27272727
m_serializer{std::make_unique<V1TransportSerializer>(V1TransportSerializer())},
27282728
m_sock{sock},
@@ -2735,7 +2735,7 @@ CNode::CNode(NodeId idIn,
27352735
id{idIn},
27362736
nLocalHostNonce{nLocalHostNonceIn},
27372737
m_conn_type{conn_type_in},
2738-
m_i2p_sam_session{std::move(i2p_sam_session)}
2738+
m_i2p_sam_session{std::move(node_opts.i2p_sam_session)}
27392739
{
27402740
if (inbound_onion) assert(conn_type_in == ConnectionType::INBOUND);
27412741

src/net.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,11 @@ class V1TransportSerializer : public TransportSerializer {
334334
void prepareForTransport(CSerializedNetMsg& msg, std::vector<unsigned char>& header) const override;
335335
};
336336

337+
struct CNodeOptions
338+
{
339+
std::unique_ptr<i2p::sam::Session> i2p_sam_session = nullptr;
340+
};
341+
337342
/** Information about a peer */
338343
class CNode
339344
{
@@ -522,7 +527,7 @@ class CNode
522527
const std::string& addrNameIn,
523528
ConnectionType conn_type_in,
524529
bool inbound_onion,
525-
std::unique_ptr<i2p::sam::Session>&& i2p_sam_session = nullptr);
530+
CNodeOptions&& node_opts = {});
526531
CNode(const CNode&) = delete;
527532
CNode& operator=(const CNode&) = delete;
528533

0 commit comments

Comments
 (0)