Skip to content

Commit 67757cd

Browse files
committed
net: pass CConnman via pointer rather than reference
There are a few too many edge-cases here to make this a scripted diff. The following commits will move a few functions into PeerLogicValidation, where the local connman instance can be used. This change prepares for that usage. Adapted from btc@28f11e9406b185dc87144f1f29af0d93eb115b4e
1 parent fbebade commit 67757cd

File tree

4 files changed

+75
-75
lines changed

4 files changed

+75
-75
lines changed

src/net.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,7 +1066,7 @@ void CConnman::AcceptConnection(const ListenSocket& hListenSocket) {
10661066
CNode* pnode = new CNode(id, nLocalServices, GetBestHeight(), hSocket, addr, CalculateKeyedNetGroup(addr), nonce, "", true);
10671067
pnode->AddRef();
10681068
pnode->fWhitelisted = whitelisted;
1069-
GetNodeSignals().InitializeNode(pnode, *this);
1069+
GetNodeSignals().InitializeNode(pnode, this);
10701070

10711071
LogPrint(BCLog::NET, "connection from %s accepted\n", addr.ToString());
10721072

@@ -1828,7 +1828,7 @@ bool CConnman::OpenNetworkConnection(const CAddress& addrConnect, bool fCountFai
18281828
if (fFeeler)
18291829
pnode->fFeeler = true;
18301830

1831-
GetNodeSignals().InitializeNode(pnode, *this);
1831+
GetNodeSignals().InitializeNode(pnode, this);
18321832
{
18331833
LOCK(cs_vNodes);
18341834
vNodes.push_back(pnode);
@@ -1856,15 +1856,15 @@ void CConnman::ThreadMessageHandler()
18561856
continue;
18571857

18581858
// Receive messages
1859-
bool fMoreNodeWork = GetNodeSignals().ProcessMessages(pnode, *this, flagInterruptMsgProc);
1859+
bool fMoreNodeWork = GetNodeSignals().ProcessMessages(pnode, this, flagInterruptMsgProc);
18601860
fMoreWork |= (fMoreNodeWork && !pnode->fPauseSend);
18611861
if (flagInterruptMsgProc)
18621862
return;
18631863

18641864
// Send messages
18651865
{
18661866
LOCK(pnode->cs_sendProcessing);
1867-
GetNodeSignals().SendMessages(pnode, *this, flagInterruptMsgProc);
1867+
GetNodeSignals().SendMessages(pnode, this, flagInterruptMsgProc);
18681868
}
18691869
if (flagInterruptMsgProc)
18701870
return;
@@ -2105,7 +2105,7 @@ bool CConnman::Start(CScheduler& scheduler, std::string& strNodeError, Options c
21052105
uint64_t nonce = GetDeterministicRandomizer(RANDOMIZER_ID_LOCALHOSTNONCE).Write(id).Finalize();
21062106

21072107
pnodeLocalHost = new CNode(id, nLocalServices, GetBestHeight(), INVALID_SOCKET, CAddress(CService(local, 0), nLocalServices), 0, nonce);
2108-
GetNodeSignals().InitializeNode(pnodeLocalHost, *this);
2108+
GetNodeSignals().InitializeNode(pnodeLocalHost, this);
21092109
}
21102110

21112111
//

src/net.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -413,9 +413,9 @@ struct CombinerAll {
413413
// Signals for message handling
414414
struct CNodeSignals
415415
{
416-
boost::signals2::signal<bool (CNode*, CConnman&, std::atomic<bool>&), CombinerAll> ProcessMessages;
417-
boost::signals2::signal<bool (CNode*, CConnman&, std::atomic<bool>&), CombinerAll> SendMessages;
418-
boost::signals2::signal<void (CNode*, CConnman&)> InitializeNode;
416+
boost::signals2::signal<bool (CNode*, CConnman*, std::atomic<bool>&), CombinerAll> ProcessMessages;
417+
boost::signals2::signal<bool (CNode*, CConnman*, std::atomic<bool>&), CombinerAll> SendMessages;
418+
boost::signals2::signal<void (CNode*, CConnman*)> InitializeNode;
419419
boost::signals2::signal<void (NodeId, bool&)> FinalizeNode;
420420
};
421421

0 commit comments

Comments
 (0)