v30.3-roots.1 · Commit 3: [PATCH 03/68] feat(policy): preserve Roots relay and network controls on Core 30.3
src/policy/rbf.cpp
Before: src/policy/rbf.cpp · After: src/policy/rbf.cpp
File metadata
index 210b94915ccb2e851bf00b87b0799b9590481674..06dc3d701358aa86e9208e3133057a026fa46b19 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 |
uint64_t nConflictingCount = 0;
|
|
@@ -69,7 +71,7 @@ std::optional<std::string> GetEntriesForConflicts(const CTransaction& tx,
|
|
| 69 |
// entries from the mempool. This potentially overestimates the number of actual
|
| 70 |
// descendants (i.e. if multiple conflicts share a descendant, it will be counted multiple
|
| 71 |
// times), but we just want to be conservative to avoid doing too much work.
|
| 72 |
-
if (nConflictingCount > MAX_REPLACEMENT_CANDIDATES) {
|
| 73 |
return strprintf("rejecting replacement %s; too many potential replacements (%d > %d)",
|
| 74 |
tx.GetHash().ToString(),
|
| 75 |
nConflictingCount,
|
|
@@ -116,12 +118,17 @@ std::optional<std::string> HasNoNewUnconfirmed(const CTransaction& tx,
|
|
| 116 |
}
|
| 117 |
|
| 118 |
std::optional<std::string> EntriesAndTxidsDisjoint(const CTxMemPool::setEntries& ancestors,
|
| 119 |
-
const std::set<Txid>& direct_conflicts,
|
| 120 |
-
const Txid& txid)
|
| 121 |
{
|
| 122 |
for (CTxMemPool::txiter ancestorIt : ancestors) {
|
| 123 |
const Txid& hashAncestor = ancestorIt->GetTx().GetHash();
|
| 124 |
-
if (direct_conflicts.count(hashAncestor)) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 125 |
return strprintf("%s spends conflicting transaction %s",
|
| 126 |
txid.ToString(),
|
| 127 |
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 |
uint64_t nConflictingCount = 0;
|
|
|
|
| 71 |
// entries from the mempool. This potentially overestimates the number of actual
|
| 72 |
// descendants (i.e. if multiple conflicts share a descendant, it will be counted multiple
|
| 73 |
// times), but we just want to be conservative to avoid doing too much work.
|
| 74 |
+
if (nConflictingCount > MAX_REPLACEMENT_CANDIDATES && !ignore_rejects.count("too-many-replacements") && !ignore_rejects.count("too many potential replacements")) {
|
| 75 |
return strprintf("rejecting replacement %s; too many potential replacements (%d > %d)",
|
| 76 |
tx.GetHash().ToString(),
|
| 77 |
nConflictingCount,
|
|
|
|
| 118 |
}
|
| 119 |
|
| 120 |
std::optional<std::string> EntriesAndTxidsDisjoint(const CTxMemPool::setEntries& ancestors,
|
| 121 |
+
const std::map<Txid, bool>& direct_conflicts,
|
| 122 |
+
const Txid& txid, bool* const out_violates_policy)
|
| 123 |
{
|
| 124 |
for (CTxMemPool::txiter ancestorIt : ancestors) {
|
| 125 |
const Txid& hashAncestor = ancestorIt->GetTx().GetHash();
|
| 126 |
+
const auto& conflictit = direct_conflicts.find(hashAncestor);
|
| 127 |
+
if (conflictit != direct_conflicts.end()) {
|
| 128 |
+
if (!conflictit->second /* mere SPK conflict, NOT invalid */) {
|
| 129 |
+
if (out_violates_policy) *out_violates_policy = true;
|
| 130 |
+
continue;
|
| 131 |
+
}
|
| 132 |
return strprintf("%s spends conflicting transaction %s",
|
| 133 |
txid.ToString(),
|
| 134 |
hashAncestor.ToString());
|