aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Todd <pete@petertodd.org>2015-11-10 17:58:06 -0500
committerPeter Todd <pete@petertodd.org>2015-11-10 18:00:24 -0500
commit16a2f93629f75d182871f288f0396afe6cdc8504 (patch)
tree8c35d8db6297f5c195bf7df4ee4f1281810ba671 /src
parent97203f5606bf76a233928adafb0ce22f15caf7ae (diff)
downloadbitcoin-16a2f93629f75d182871f288f0396afe6cdc8504.tar.xz
Fix incorrect locking of mempool during RBF replacement
Previously RemoveStaged() was called without pool.cs held.
Diffstat (limited to 'src')
-rw-r--r--src/main.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 79d4c91b77..e3527a83d1 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1006,10 +1006,13 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
size_t nConflictingSize = 0;
uint64_t nConflictingCount = 0;
CTxMemPool::setEntries allConflicting;
+
+ // If we don't hold the lock allConflicting might be incomplete; the
+ // subsequent RemoveStaged() and addUnchecked() calls don't guarantee
+ // mempool consistency for us.
+ LOCK(pool.cs);
if (setConflicts.size())
{
- LOCK(pool.cs);
-
CFeeRate newFeeRate(nFees, nSize);
set<uint256> setConflictsParents;
const int maxDescendantsToVisit = 100;