Skip to content

Commit 16a2f93

Browse files
committed
Fix incorrect locking of mempool during RBF replacement
Previously RemoveStaged() was called without pool.cs held.
1 parent 97203f5 commit 16a2f93

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/main.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,10 +1006,13 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
10061006
size_t nConflictingSize = 0;
10071007
uint64_t nConflictingCount = 0;
10081008
CTxMemPool::setEntries allConflicting;
1009+
1010+
// If we don't hold the lock allConflicting might be incomplete; the
1011+
// subsequent RemoveStaged() and addUnchecked() calls don't guarantee
1012+
// mempool consistency for us.
1013+
LOCK(pool.cs);
10091014
if (setConflicts.size())
10101015
{
1011-
LOCK(pool.cs);
1012-
10131016
CFeeRate newFeeRate(nFees, nSize);
10141017
set<uint256> setConflictsParents;
10151018
const int maxDescendantsToVisit = 100;

0 commit comments

Comments
 (0)