diff options
author | glozow <gloriajzhao@gmail.com> | 2021-07-27 14:23:40 +0100 |
---|---|---|
committer | glozow <gloriajzhao@gmail.com> | 2021-08-24 15:51:54 +0100 |
commit | f293c68be0469894c988711559f5528020c0ff71 (patch) | |
tree | 4bcd1740db9364d2801ce5268d84b10819233d9b /src/validation.cpp | |
parent | 8d7179633552f58ca0d23305196dcb4249b6dce7 (diff) |
MOVEONLY: getting mempool conflicts to policy/rbf
Diffstat (limited to 'src/validation.cpp')
-rw-r--r-- | src/validation.cpp | 23 |
1 files changed, 5 insertions, 18 deletions
diff --git a/src/validation.cpp b/src/validation.cpp index fdcf128924..5baa9f5fd8 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -789,6 +789,7 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws) fReplacementTransaction = setConflicts.size(); if (fReplacementTransaction) { + std::string err_string; CFeeRate newFeeRate(nModifiedFees, nSize); for (const auto& mi : setIterConflicting) { // Don't allow the replacement to reduce the feerate of the @@ -816,25 +817,11 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws) } } - uint64_t nConflictingCount = 0; - for (const auto& mi : setIterConflicting) { - nConflictingCount += mi->GetCountWithDescendants(); - // This potentially overestimates the number of actual descendants - // but we just want to be conservative to avoid doing too much - // work. - if (nConflictingCount > MAX_BIP125_REPLACEMENT_CANDIDATES) { - return state.Invalid(TxValidationResult::TX_MEMPOOL_POLICY, "too many potential replacements", - strprintf("rejecting replacement %s; too many potential replacements (%d > %d)\n", - hash.ToString(), - nConflictingCount, - MAX_BIP125_REPLACEMENT_CANDIDATES)); - } - } - // If not too many to replace, then calculate the set of - // transactions that would have to be evicted - for (CTxMemPool::txiter it : setIterConflicting) { - m_pool.CalculateDescendants(it, allConflicting); + // Calculate all conflicting entries and enforce Rule #5. + if (!GetEntriesForConflicts(tx, m_pool, setIterConflicting, allConflicting, err_string)) { + return state.Invalid(TxValidationResult::TX_MEMPOOL_POLICY, "too many potential replacements", err_string); } + // Check if it's economically rational to mine this transaction rather // than the ones it replaces. for (CTxMemPool::txiter it : allConflicting) { |