diff options
author | Jeff Garzik <jeff@garzik.org> | 2012-04-17 12:30:00 -0400 |
---|---|---|
committer | Luke Dashjr <luke-jr+git@utopios.org> | 2012-04-17 14:40:58 -0400 |
commit | 1175d8f6a1782da777f406a8400b7281a7af09e7 (patch) | |
tree | f95cc205c4ce3678f4755a5bc7ca4a32db527c95 /src/main.cpp | |
parent | 12570da46ff9de4201ae9f3411db0e955d2993de (diff) | |
download | bitcoin-1175d8f6a1782da777f406a8400b7281a7af09e7.tar.xz |
AlreadyHave(): only hold lock during mapTransactions access
Diffstat (limited to 'src/main.cpp')
-rw-r--r-- | src/main.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/main.cpp b/src/main.cpp index 57c18aed48..f13b884f96 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1954,11 +1954,15 @@ bool static AlreadyHave(CTxDB& txdb, const CInv& inv) switch (inv.type) { case MSG_TX: + { + bool txInMap = false; CRITICAL_BLOCK(cs_mapTransactions) { - return mapTransactions.count(inv.hash) || - mapOrphanTransactions.count(inv.hash) || - txdb.ContainsTx(inv.hash); + txInMap = (mapTransactions.count(inv.hash) != 0); + } + return txInMap || + mapOrphanTransactions.count(inv.hash) || + txdb.ContainsTx(inv.hash); } case MSG_BLOCK: return mapBlockIndex.count(inv.hash) || mapOrphanBlocks.count(inv.hash); |