Skip to content
Bitcoin Roots

v29.4-roots.1 · Commit 3: [PATCH 03/13] 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. Before is on the left; after is on the right. Unified view fits narrow screens more easily.

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