Skip to content

Commit 6452190

Browse files
committed
net_processing: simplify MaybeSetPeerAsAnnouncingHeaderAndIDs args
No need to pass connman to PeerManagerImpl methods.
1 parent 39c2a69 commit 6452190

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/net_processing.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ class PeerManagerImpl final : public PeerManager
458458
* lNodesAnnouncingHeaderAndIDs, and keeping that list under a certain size by
459459
* removing the first element if necessary.
460460
*/
461-
void MaybeSetPeerAsAnnouncingHeaderAndIDs(NodeId nodeid, CConnman& connman) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
461+
void MaybeSetPeerAsAnnouncingHeaderAndIDs(NodeId nodeid) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
462462

463463
/** Stack of nodes which we have set to announce using compact blocks */
464464
std::list<NodeId> lNodesAnnouncingHeaderAndIDs GUARDED_BY(cs_main);
@@ -739,7 +739,7 @@ static void UpdateBlockAvailability(NodeId nodeid, const uint256 &hash) EXCLUSIV
739739
}
740740
}
741741

742-
void PeerManagerImpl::MaybeSetPeerAsAnnouncingHeaderAndIDs(NodeId nodeid, CConnman& connman) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
742+
void PeerManagerImpl::MaybeSetPeerAsAnnouncingHeaderAndIDs(NodeId nodeid) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
743743
{
744744
AssertLockHeld(cs_main);
745745
CNodeState* nodestate = State(nodeid);
@@ -755,21 +755,21 @@ void PeerManagerImpl::MaybeSetPeerAsAnnouncingHeaderAndIDs(NodeId nodeid, CConnm
755755
return;
756756
}
757757
}
758-
connman.ForNode(nodeid, [this, &connman](CNode* pfrom) EXCLUSIVE_LOCKS_REQUIRED(::cs_main) {
758+
m_connman.ForNode(nodeid, [this](CNode* pfrom) EXCLUSIVE_LOCKS_REQUIRED(::cs_main) {
759759
AssertLockHeld(::cs_main);
760760
uint64_t nCMPCTBLOCKVersion = (pfrom->GetLocalServices() & NODE_WITNESS) ? 2 : 1;
761761
if (lNodesAnnouncingHeaderAndIDs.size() >= 3) {
762762
// As per BIP152, we only get 3 of our peers to announce
763763
// blocks using compact encodings.
764-
connman.ForNode(lNodesAnnouncingHeaderAndIDs.front(), [&connman, nCMPCTBLOCKVersion](CNode* pnodeStop){
765-
connman.PushMessage(pnodeStop, CNetMsgMaker(pnodeStop->GetCommonVersion()).Make(NetMsgType::SENDCMPCT, /*fAnnounceUsingCMPCTBLOCK=*/false, nCMPCTBLOCKVersion));
764+
m_connman.ForNode(lNodesAnnouncingHeaderAndIDs.front(), [this, nCMPCTBLOCKVersion](CNode* pnodeStop){
765+
m_connman.PushMessage(pnodeStop, CNetMsgMaker(pnodeStop->GetCommonVersion()).Make(NetMsgType::SENDCMPCT, /*fAnnounceUsingCMPCTBLOCK=*/false, nCMPCTBLOCKVersion));
766766
// save BIP152 bandwidth state: we select peer to be low-bandwidth
767767
pnodeStop->m_bip152_highbandwidth_to = false;
768768
return true;
769769
});
770770
lNodesAnnouncingHeaderAndIDs.pop_front();
771771
}
772-
connman.PushMessage(pfrom, CNetMsgMaker(pfrom->GetCommonVersion()).Make(NetMsgType::SENDCMPCT, /*fAnnounceUsingCMPCTBLOCK=*/true, nCMPCTBLOCKVersion));
772+
m_connman.PushMessage(pfrom, CNetMsgMaker(pfrom->GetCommonVersion()).Make(NetMsgType::SENDCMPCT, /*fAnnounceUsingCMPCTBLOCK=*/true, nCMPCTBLOCKVersion));
773773
// save BIP152 bandwidth state: we select peer to be high-bandwidth
774774
pfrom->m_bip152_highbandwidth_to = true;
775775
lNodesAnnouncingHeaderAndIDs.push_back(pfrom->GetId());
@@ -1578,7 +1578,7 @@ void PeerManagerImpl::BlockChecked(const CBlock& block, const BlockValidationSta
15781578
!::ChainstateActive().IsInitialBlockDownload() &&
15791579
mapBlocksInFlight.count(hash) == mapBlocksInFlight.size()) {
15801580
if (it != mapBlockSource.end()) {
1581-
MaybeSetPeerAsAnnouncingHeaderAndIDs(it->second.first, m_connman);
1581+
MaybeSetPeerAsAnnouncingHeaderAndIDs(it->second.first);
15821582
}
15831583
}
15841584
if (it != mapBlockSource.end())

0 commit comments

Comments
 (0)