mirror of
https://github.com/bitcoin/bitcoin.git
synced 2024-11-19 18:09:47 +01:00
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.
This commit is contained in:
parent
7f609f68d8
commit
af9ea55a72
@ -628,13 +628,12 @@ static void MaybeSetPeerAsAnnouncingHeaderAndIDs(NodeId nodeid, CConnman& connma
|
||||
}
|
||||
}
|
||||
connman.ForNode(nodeid, [&connman](CNode* pfrom){
|
||||
AssertLockHeld(cs_main);
|
||||
LockAssertion lock(::cs_main);
|
||||
uint64_t nCMPCTBLOCKVersion = (pfrom->GetLocalServices() & NODE_WITNESS) ? 2 : 1;
|
||||
if (lNodesAnnouncingHeaderAndIDs.size() >= 3) {
|
||||
// As per BIP152, we only get 3 of our peers to announce
|
||||
// blocks using compact encodings.
|
||||
connman.ForNode(lNodesAnnouncingHeaderAndIDs.front(), [&connman, nCMPCTBLOCKVersion](CNode* pnodeStop){
|
||||
AssertLockHeld(cs_main);
|
||||
connman.PushMessage(pnodeStop, CNetMsgMaker(pnodeStop->GetSendVersion()).Make(NetMsgType::SENDCMPCT, /*fAnnounceUsingCMPCTBLOCK=*/false, nCMPCTBLOCKVersion));
|
||||
return true;
|
||||
});
|
||||
@ -1327,7 +1326,7 @@ void PeerLogicValidation::NewPoWValidBlock(const CBlockIndex *pindex, const std:
|
||||
}
|
||||
|
||||
m_connman.ForEachNode([this, &pcmpctblock, pindex, &msgMaker, fWitnessEnabled, &hashBlock](CNode* pnode) {
|
||||
AssertLockHeld(cs_main);
|
||||
LockAssertion lock(::cs_main);
|
||||
|
||||
// TODO: Avoid the repeated-serialization here
|
||||
if (pnode->nVersion < INVALID_CB_NO_BAN_VERSION || pnode->fDisconnect)
|
||||
@ -1469,7 +1468,8 @@ void RelayTransaction(const uint256& txid, const uint256& wtxid, const CConnman&
|
||||
{
|
||||
connman.ForEachNode([&txid, &wtxid](CNode* pnode)
|
||||
{
|
||||
AssertLockHeld(cs_main);
|
||||
LockAssertion lock(::cs_main);
|
||||
|
||||
CNodeState &state = *State(pnode->GetId());
|
||||
if (state.m_wtxid_relay) {
|
||||
pnode->PushTxInventory(wtxid);
|
||||
@ -3957,7 +3957,7 @@ void PeerLogicValidation::EvictExtraOutboundPeers(int64_t time_in_seconds)
|
||||
int64_t oldest_block_announcement = std::numeric_limits<int64_t>::max();
|
||||
|
||||
m_connman.ForEachNode([&](CNode* pnode) {
|
||||
AssertLockHeld(cs_main);
|
||||
LockAssertion lock(::cs_main);
|
||||
|
||||
// Ignore non-outbound peers, or nodes marked for disconnect already
|
||||
if (!pnode->IsOutboundOrBlockRelayConn() || pnode->fDisconnect) return;
|
||||
@ -3974,7 +3974,7 @@ void PeerLogicValidation::EvictExtraOutboundPeers(int64_t time_in_seconds)
|
||||
});
|
||||
if (worst_peer != -1) {
|
||||
bool disconnected = m_connman.ForNode(worst_peer, [&](CNode *pnode) {
|
||||
AssertLockHeld(cs_main);
|
||||
LockAssertion lock(::cs_main);
|
||||
|
||||
// Only disconnect a peer that has been connected to us for
|
||||
// some reasonable fraction of our check-frequency, to give
|
||||
|
Loading…
Reference in New Issue
Block a user