MCPcopy Create free account
hub / github.com/ElementsProject/elements / GetEntriesForConflicts

Function GetEntriesForConflicts

src/policy/rbf.cpp:50–76  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

48}
49
50std::optional<std::string> GetEntriesForConflicts(const CTransaction& tx,
51 CTxMemPool& pool,
52 const CTxMemPool::setEntries& iters_conflicting,
53 CTxMemPool::setEntries& all_conflicts)
54{
55 AssertLockHeld(pool.cs);
56 const uint256 txid = tx.GetHash();
57 uint64_t nConflictingCount = 0;
58 for (const auto& mi : iters_conflicting) {
59 nConflictingCount += mi->GetCountWithDescendants();
60 // BIP125 Rule #5: don't consider replacing more than MAX_BIP125_REPLACEMENT_CANDIDATES
61 // entries from the mempool. This potentially overestimates the number of actual
62 // descendants (i.e. if multiple conflicts share a descendant, it will be counted multiple
63 // times), but we just want to be conservative to avoid doing too much work.
64 if (nConflictingCount > MAX_BIP125_REPLACEMENT_CANDIDATES) {
65 return strprintf("rejecting replacement %s; too many potential replacements (%d > %d)\n",
66 txid.ToString(),
67 nConflictingCount,
68 MAX_BIP125_REPLACEMENT_CANDIDATES);
69 }
70 }
71 // Calculate the set of all transactions that would have to be evicted.
72 for (CTxMemPool::txiter it : iters_conflicting) {
73 pool.CalculateDescendants(it, all_conflicts);
74 }
75 return std::nullopt;
76}
77
78std::optional<std::string> HasNoNewUnconfirmed(const CTransaction& tx,
79 const CTxMemPool& pool,

Callers 1

ReplacementChecksMethod · 0.85

Calls 4

CalculateDescendantsMethod · 0.80
GetHashMethod · 0.45
ToStringMethod · 0.45

Tested by

no test coverage detected