Skip to content
Bitcoin Roots

v29.4-roots.2 · Commit 3: [PATCH 03/21] policy: restore conservative relay and network controls

src/policy/rbf.cpp

Before: src/policy/rbf.cpp · After: src/policy/rbf.cpp

File metadata
index bc76361fba3a4894c8ab69f591dc2eedbb9428f4..913918af25715bb59571180873eeedabf5f07970 100644

Download original patch · Release notes

Diff rows 1–44 of 44. Line numbers refer to the original before/after files.

+ Added− RemovedUnmarked lines are context.

Scroll the code area horizontally to read long lines. The two line-number columns refer to before and after.

src/policy/rbf.cpp CHANGED
@@ -7,6 +7,7 @@
7
7
  #include <consensus/amount.h>
8
8
  #include <kernel/mempool_entry.h>
9
9
  #include <policy/feerate.h>
10
+ #include <policy/policy.h>
10
11
  #include <primitives/transaction.h>
11
12
  #include <sync.h>
12
13
  #include <tinyformat.h>
@@ -59,7 +60,8 @@ RBFTransactionState IsRBFOptInEmptyMempool(const CTransaction& tx)
59
60
  std::optional<std::string> GetEntriesForConflicts(const CTransaction& tx,
60
61
  CTxMemPool& pool,
61
62
  const CTxMemPool::setEntries& iters_conflicting,
62
- CTxMemPool::setEntries& all_conflicts)
63
+ CTxMemPool::setEntries& all_conflicts,
64
+ const ignore_rejects_type& ignore_rejects)
63
65
  {
64
66
  AssertLockHeld(pool.cs);
65
67
  const uint256 txid = tx.GetHash();
@@ -70,7 +72,7 @@ std::optional<std::string> GetEntriesForConflicts(const CTransaction& tx,
70
72
  // entries from the mempool. This potentially overestimates the number of actual
71
73
  // descendants (i.e. if multiple conflicts share a descendant, it will be counted multiple
72
74
  // times), but we just want to be conservative to avoid doing too much work.
73
- if (nConflictingCount > MAX_REPLACEMENT_CANDIDATES) {
75
+ if (nConflictingCount > MAX_REPLACEMENT_CANDIDATES && !ignore_rejects.count("too-many-replacements") && !ignore_rejects.count("too many potential replacements")) {
74
76
  return strprintf("rejecting replacement %s; too many potential replacements (%d > %d)",
75
77
  txid.ToString(),
76
78
  nConflictingCount,
@@ -117,12 +119,17 @@ std::optional<std::string> HasNoNewUnconfirmed(const CTransaction& tx,
117
119
  }
118
120
 
119
121
  std::optional<std::string> EntriesAndTxidsDisjoint(const CTxMemPool::setEntries& ancestors,
120
- const std::set<Txid>& direct_conflicts,
121
- const uint256& txid)
122
+ const std::map<Txid, bool>& direct_conflicts,
123
+ const uint256& txid, bool* const out_violates_policy)
122
124
  {
123
125
  for (CTxMemPool::txiter ancestorIt : ancestors) {
124
126
  const Txid& hashAncestor = ancestorIt->GetTx().GetHash();
125
- if (direct_conflicts.count(hashAncestor)) {
127
+ const auto& conflictit = direct_conflicts.find(hashAncestor);
128
+ if (conflictit != direct_conflicts.end()) {
129
+ if (!conflictit->second /* mere SPK conflict, NOT invalid */) {
130
+ if (out_violates_policy) *out_violates_policy = true;
131
+ continue;
132
+ }
126
133
  return strprintf("%s spends conflicting transaction %s",
127
134
  txid.ToString(),
128
135
  hashAncestor.ToString());