aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/policy/rbf.h4
-rw-r--r--src/validation.cpp6
-rwxr-xr-xtest/lint/lint-circular-dependencies.sh1
3 files changed, 8 insertions, 3 deletions
diff --git a/src/policy/rbf.h b/src/policy/rbf.h
index e078070c1c..d61390361b 100644
--- a/src/policy/rbf.h
+++ b/src/policy/rbf.h
@@ -7,6 +7,10 @@
#include <txmempool.h>
+/** Maximum number of transactions that can be replaced by BIP125 RBF (Rule #5). This includes all
+ * mempool conflicts and their descendants. */
+static constexpr uint32_t MAX_BIP125_REPLACEMENT_CANDIDATES{100};
+
/** The rbf state of unconfirmed transactions */
enum class RBFTransactionState {
/** Unconfirmed tx that does not signal rbf and is not in the mempool */
diff --git a/src/validation.cpp b/src/validation.cpp
index ec457da5cc..29f82c2de0 100644
--- a/src/validation.cpp
+++ b/src/validation.cpp
@@ -25,6 +25,7 @@
#include <node/coinstats.h>
#include <node/ui_interface.h>
#include <policy/policy.h>
+#include <policy/rbf.h>
#include <policy/settings.h>
#include <pow.h>
#include <primitives/block.h>
@@ -810,7 +811,6 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws)
{
CFeeRate newFeeRate(nModifiedFees, nSize);
std::set<uint256> setConflictsParents;
- const int maxDescendantsToVisit = 100;
for (const auto& mi : setIterConflicting) {
// Don't allow the replacement to reduce the feerate of the
// mempool.
@@ -846,7 +846,7 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws)
// This potentially overestimates the number of actual descendants
// but we just want to be conservative to avoid doing too much
// work.
- if (nConflictingCount <= maxDescendantsToVisit) {
+ if (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) {
@@ -861,7 +861,7 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws)
strprintf("rejecting replacement %s; too many potential replacements (%d > %d)\n",
hash.ToString(),
nConflictingCount,
- maxDescendantsToVisit));
+ MAX_BIP125_REPLACEMENT_CANDIDATES));
}
for (unsigned int j = 0; j < tx.vin.size(); j++)
diff --git a/test/lint/lint-circular-dependencies.sh b/test/lint/lint-circular-dependencies.sh
index df5051720b..233381f2d9 100755
--- a/test/lint/lint-circular-dependencies.sh
+++ b/test/lint/lint-circular-dependencies.sh
@@ -15,6 +15,7 @@ EXPECTED_CIRCULAR_DEPENDENCIES=(
"index/base -> validation -> index/blockfilterindex -> index/base"
"index/coinstatsindex -> node/coinstats -> index/coinstatsindex"
"policy/fees -> txmempool -> policy/fees"
+ "policy/rbf -> txmempool -> validation -> policy/rbf"
"qt/addresstablemodel -> qt/walletmodel -> qt/addresstablemodel"
"qt/recentrequeststablemodel -> qt/walletmodel -> qt/recentrequeststablemodel"
"qt/sendcoinsdialog -> qt/walletmodel -> qt/sendcoinsdialog"