Skip to content

Commit 62eac58

Browse files
committed
Remove redundant nested LOCK(pto->cs_inventory) in Dandelion block
The inner LOCK(pto->cs_inventory) at the Dandelion transaction processing block was redundant because the outer scope already holds the same lock. While CCriticalSection is a recursive mutex so this wouldn't deadlock, it added unnecessary overhead. Remove the redundant lock and its enclosing braces.
1 parent 03380f6 commit 62eac58

1 file changed

Lines changed: 15 additions & 18 deletions

File tree

src/net_processing.cpp

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3616,24 +3616,21 @@ bool SendMessages(CNode* pto, CConnman& connman, const std::atomic<bool>& interr
36163616
pto->vInventoryBlockToSend.clear();
36173617

36183618
// Add Dandelion transactions
3619-
{
3620-
LOCK(pto->cs_inventory);
3621-
for (const uint256& hash : pto->vInventoryDandelionTxToSend) {
3622-
pto->filterDandelionInventoryKnown.insert(hash);
3623-
uint256 dandelionServiceDiscoveryHash;
3624-
dandelionServiceDiscoveryHash.SetHex(
3625-
"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
3626-
if (!pto->fSupportsDandelion && hash != dandelionServiceDiscoveryHash) {
3627-
//LogPrintf("Pushing transaction MSG_TX %s to %s.",
3628-
// hash.ToString(), pto->addr.ToString());
3629-
vInv.push_back(CInv(MSG_TX, hash));
3630-
} else {
3631-
vInv.push_back(CInv(MSG_DANDELION_TX, hash));
3632-
}
3633-
if (vInv.size() == MAX_INV_SZ) {
3634-
connman.PushMessage(pto, msgMaker.Make(NetMsgType::INV, vInv));
3635-
vInv.clear();
3636-
}
3619+
for (const uint256& hash : pto->vInventoryDandelionTxToSend) {
3620+
pto->filterDandelionInventoryKnown.insert(hash);
3621+
uint256 dandelionServiceDiscoveryHash;
3622+
dandelionServiceDiscoveryHash.SetHex(
3623+
"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
3624+
if (!pto->fSupportsDandelion && hash != dandelionServiceDiscoveryHash) {
3625+
//LogPrintf("Pushing transaction MSG_TX %s to %s.",
3626+
// hash.ToString(), pto->addr.ToString());
3627+
vInv.push_back(CInv(MSG_TX, hash));
3628+
} else {
3629+
vInv.push_back(CInv(MSG_DANDELION_TX, hash));
3630+
}
3631+
if (vInv.size() == MAX_INV_SZ) {
3632+
connman.PushMessage(pto, msgMaker.Make(NetMsgType::INV, vInv));
3633+
vInv.clear();
36373634
}
36383635
}
36393636
pto->vInventoryDandelionTxToSend.clear();

0 commit comments

Comments
 (0)