Skip to content

Commit af9ea55

Browse files
committed
Use LockAssertion utility class instead of AssertLockHeld()
This change prepares for upcoming commit "Do not hide compile-time thread safety warnings" by replacing AssertLockHeld() with LockAssertion() where needed.
1 parent 7f609f6 commit af9ea55

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/net_processing.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -628,13 +628,12 @@ static void MaybeSetPeerAsAnnouncingHeaderAndIDs(NodeId nodeid, CConnman& connma
628628
}
629629
}
630630
connman.ForNode(nodeid, [&connman](CNode* pfrom){
631-
AssertLockHeld(cs_main);
631+
LockAssertion lock(::cs_main);
632632
uint64_t nCMPCTBLOCKVersion = (pfrom->GetLocalServices() & NODE_WITNESS) ? 2 : 1;
633633
if (lNodesAnnouncingHeaderAndIDs.size() >= 3) {
634634
// As per BIP152, we only get 3 of our peers to announce
635635
// blocks using compact encodings.
636636
connman.ForNode(lNodesAnnouncingHeaderAndIDs.front(), [&connman, nCMPCTBLOCKVersion](CNode* pnodeStop){
637-
AssertLockHeld(cs_main);
638637
connman.PushMessage(pnodeStop, CNetMsgMaker(pnodeStop->GetSendVersion()).Make(NetMsgType::SENDCMPCT, /*fAnnounceUsingCMPCTBLOCK=*/false, nCMPCTBLOCKVersion));
639638
return true;
640639
});
@@ -1327,7 +1326,7 @@ void PeerLogicValidation::NewPoWValidBlock(const CBlockIndex *pindex, const std:
13271326
}
13281327

13291328
m_connman.ForEachNode([this, &pcmpctblock, pindex, &msgMaker, fWitnessEnabled, &hashBlock](CNode* pnode) {
1330-
AssertLockHeld(cs_main);
1329+
LockAssertion lock(::cs_main);
13311330

13321331
// TODO: Avoid the repeated-serialization here
13331332
if (pnode->nVersion < INVALID_CB_NO_BAN_VERSION || pnode->fDisconnect)
@@ -1469,7 +1468,8 @@ void RelayTransaction(const uint256& txid, const uint256& wtxid, const CConnman&
14691468
{
14701469
connman.ForEachNode([&txid, &wtxid](CNode* pnode)
14711470
{
1472-
AssertLockHeld(cs_main);
1471+
LockAssertion lock(::cs_main);
1472+
14731473
CNodeState &state = *State(pnode->GetId());
14741474
if (state.m_wtxid_relay) {
14751475
pnode->PushTxInventory(wtxid);
@@ -3957,7 +3957,7 @@ void PeerLogicValidation::EvictExtraOutboundPeers(int64_t time_in_seconds)
39573957
int64_t oldest_block_announcement = std::numeric_limits<int64_t>::max();
39583958

39593959
m_connman.ForEachNode([&](CNode* pnode) {
3960-
AssertLockHeld(cs_main);
3960+
LockAssertion lock(::cs_main);
39613961

39623962
// Ignore non-outbound peers, or nodes marked for disconnect already
39633963
if (!pnode->IsOutboundOrBlockRelayConn() || pnode->fDisconnect) return;
@@ -3974,7 +3974,7 @@ void PeerLogicValidation::EvictExtraOutboundPeers(int64_t time_in_seconds)
39743974
});
39753975
if (worst_peer != -1) {
39763976
bool disconnected = m_connman.ForNode(worst_peer, [&](CNode *pnode) {
3977-
AssertLockHeld(cs_main);
3977+
LockAssertion lock(::cs_main);
39783978

39793979
// Only disconnect a peer that has been connected to us for
39803980
// some reasonable fraction of our check-frequency, to give

0 commit comments

Comments
 (0)