refactor: Separate peer/maybe_peer in ProcessMessages and SendMessages
Introducing two names to refer to the peer makes it possible to have one refer to a non-null reference in a later commit.
This commit is contained in:
1 file changed
+6
-4
@@ -5186,8 +5186,9 @@ bool PeerManagerImpl::ProcessMessages(CNode& node, std::atomic<bool>& interruptM
|
|||||||
AssertLockHeld(g_msgproc_mutex);
|
AssertLockHeld(g_msgproc_mutex);
|
||||||
|
|
||||||
CNode* pfrom{&node}; // alias removed in a later commit.
|
CNode* pfrom{&node}; // alias removed in a later commit.
|
||||||
PeerRef peer = GetPeerRef(pfrom->GetId());
|
PeerRef maybe_peer{GetPeerRef(pfrom->GetId())};
|
||||||
if (peer == nullptr) return false;
|
if (maybe_peer == nullptr) return false;
|
||||||
|
auto& peer{maybe_peer}; // alias cleaned up in later commit.
|
||||||
|
|
||||||
// For outbound connections, ensure that the initial VERSION message
|
// For outbound connections, ensure that the initial VERSION message
|
||||||
// has been sent first before processing any incoming messages
|
// has been sent first before processing any incoming messages
|
||||||
@@ -5689,8 +5690,9 @@ bool PeerManagerImpl::SendMessages(CNode& node)
|
|||||||
AssertLockHeld(g_msgproc_mutex);
|
AssertLockHeld(g_msgproc_mutex);
|
||||||
|
|
||||||
CNode* pto{&node}; // alias removed in a later commit
|
CNode* pto{&node}; // alias removed in a later commit
|
||||||
PeerRef peer = GetPeerRef(pto->GetId());
|
PeerRef maybe_peer{GetPeerRef(pto->GetId())};
|
||||||
if (!peer) return false;
|
if (!maybe_peer) return false;
|
||||||
|
auto& peer{maybe_peer}; // alias cleaned up in later commit
|
||||||
const Consensus::Params& consensusParams = m_chainparams.GetConsensus();
|
const Consensus::Params& consensusParams = m_chainparams.GetConsensus();
|
||||||
|
|
||||||
// We must call MaybeDiscourageAndDisconnect first, to ensure that we'll
|
// We must call MaybeDiscourageAndDisconnect first, to ensure that we'll
|
||||||
|
|||||||
Reference in new issue
Block a user