mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-09 11:27:28 -03:00
Remove m_all_conflicts from SubPackageState
This commit is contained in:
parent
d3c8e7dfb6
commit
83f814b1d1
2 changed files with 14 additions and 14 deletions
|
@ -804,6 +804,8 @@ public:
|
|||
TxHandle StageAddition(const CTransactionRef& tx, const CAmount fee, int64_t time, unsigned int entry_height, uint64_t entry_sequence, bool spends_coinbase, int64_t sigops_cost, LockPoints lp);
|
||||
void StageRemoval(CTxMemPool::txiter it) { m_to_remove.insert(it); }
|
||||
|
||||
const CTxMemPool::setEntries& GetRemovals() const { return m_to_remove; }
|
||||
|
||||
util::Result<CTxMemPool::setEntries> CalculateMemPoolAncestors(TxHandle tx, const Limits& limits)
|
||||
{
|
||||
// Look up transaction in our cache first
|
||||
|
|
|
@ -635,7 +635,7 @@ private:
|
|||
CTxMemPool::setEntries m_ancestors;
|
||||
/* Handle to the tx in the changeset */
|
||||
CTxMemPool::ChangeSet::TxHandle m_tx_handle;
|
||||
/** Whether RBF-related data structures (m_conflicts, m_iters_conflicting, m_all_conflicting,
|
||||
/** Whether RBF-related data structures (m_conflicts, m_iters_conflicting,
|
||||
* m_replaced_transactions) include a sibling in addition to txns with conflicting inputs. */
|
||||
bool m_sibling_eviction{false};
|
||||
|
||||
|
@ -739,8 +739,6 @@ private:
|
|||
/** Whether the transaction(s) would replace any mempool transactions and/or evict any siblings.
|
||||
* If so, RBF rules apply. */
|
||||
bool m_rbf{false};
|
||||
/** All directly conflicting mempool transactions and their descendants. */
|
||||
CTxMemPool::setEntries m_all_conflicts;
|
||||
/** Mempool transactions that were replaced. */
|
||||
std::list<CTransactionRef> m_replaced_transactions;
|
||||
/* Changeset representing adding transactions and removing their conflicts. */
|
||||
|
@ -1089,13 +1087,15 @@ bool MemPoolAccept::ReplacementChecks(Workspace& ws)
|
|||
strprintf("insufficient fee%s", ws.m_sibling_eviction ? " (including sibling eviction)" : ""), *err_string);
|
||||
}
|
||||
|
||||
CTxMemPool::setEntries all_conflicts;
|
||||
|
||||
// Calculate all conflicting entries and enforce Rule #5.
|
||||
if (const auto err_string{GetEntriesForConflicts(tx, m_pool, ws.m_iters_conflicting, m_subpackage.m_all_conflicts)}) {
|
||||
if (const auto err_string{GetEntriesForConflicts(tx, m_pool, ws.m_iters_conflicting, all_conflicts)}) {
|
||||
return state.Invalid(TxValidationResult::TX_MEMPOOL_POLICY,
|
||||
strprintf("too many potential replacements%s", ws.m_sibling_eviction ? " (including sibling eviction)" : ""), *err_string);
|
||||
}
|
||||
// Enforce Rule #2.
|
||||
if (const auto err_string{HasNoNewUnconfirmed(tx, m_pool, m_subpackage.m_all_conflicts)}) {
|
||||
if (const auto err_string{HasNoNewUnconfirmed(tx, m_pool, all_conflicts)}) {
|
||||
// Sibling eviction is only done for TRUC transactions, which cannot have multiple ancestors.
|
||||
Assume(!ws.m_sibling_eviction);
|
||||
return state.Invalid(TxValidationResult::TX_MEMPOOL_POLICY,
|
||||
|
@ -1104,7 +1104,7 @@ bool MemPoolAccept::ReplacementChecks(Workspace& ws)
|
|||
|
||||
// Check if it's economically rational to mine this transaction rather than the ones it
|
||||
// replaces and pays for its own relay fees. Enforce Rules #3 and #4.
|
||||
for (CTxMemPool::txiter it : m_subpackage.m_all_conflicts) {
|
||||
for (CTxMemPool::txiter it : all_conflicts) {
|
||||
m_subpackage.m_conflicting_fees += it->GetModifiedFee();
|
||||
m_subpackage.m_conflicting_size += it->GetTxSize();
|
||||
}
|
||||
|
@ -1116,7 +1116,7 @@ bool MemPoolAccept::ReplacementChecks(Workspace& ws)
|
|||
}
|
||||
|
||||
// Add all the to-be-removed transactions to the changeset.
|
||||
for (auto it : m_subpackage.m_all_conflicts) {
|
||||
for (auto it : all_conflicts) {
|
||||
m_subpackage.m_changeset->StageRemoval(it);
|
||||
}
|
||||
return true;
|
||||
|
@ -1172,14 +1172,15 @@ bool MemPoolAccept::PackageMempoolChecks(const std::vector<CTransactionRef>& txn
|
|||
|
||||
// Don't consider replacements that would cause us to remove a large number of mempool entries.
|
||||
// This limit is not increased in a package RBF. Use the aggregate number of transactions.
|
||||
CTxMemPool::setEntries all_conflicts;
|
||||
if (const auto err_string{GetEntriesForConflicts(*child_ws.m_ptx, m_pool, direct_conflict_iters,
|
||||
m_subpackage.m_all_conflicts)}) {
|
||||
all_conflicts)}) {
|
||||
return package_state.Invalid(PackageValidationResult::PCKG_POLICY,
|
||||
"package RBF failed: too many potential replacements", *err_string);
|
||||
}
|
||||
|
||||
|
||||
for (CTxMemPool::txiter it : m_subpackage.m_all_conflicts) {
|
||||
for (CTxMemPool::txiter it : all_conflicts) {
|
||||
m_subpackage.m_changeset->StageRemoval(it);
|
||||
m_subpackage.m_conflicting_fees += it->GetModifiedFee();
|
||||
m_subpackage.m_conflicting_size += it->GetTxSize();
|
||||
|
@ -1287,9 +1288,9 @@ void MemPoolAccept::FinalizeSubpackage(const ATMPArgs& args)
|
|||
AssertLockHeld(cs_main);
|
||||
AssertLockHeld(m_pool.cs);
|
||||
|
||||
if (!m_subpackage.m_all_conflicts.empty()) Assume(args.m_allow_replacement);
|
||||
if (!m_subpackage.m_changeset->GetRemovals().empty()) Assume(args.m_allow_replacement);
|
||||
// Remove conflicting transactions from the mempool
|
||||
for (CTxMemPool::txiter it : m_subpackage.m_all_conflicts)
|
||||
for (CTxMemPool::txiter it : m_subpackage.m_changeset->GetRemovals())
|
||||
{
|
||||
std::string log_string = strprintf("replacing mempool tx %s (wtxid=%s, fees=%s, vsize=%s). ",
|
||||
it->GetTx().GetHash().ToString(),
|
||||
|
@ -1329,9 +1330,6 @@ void MemPoolAccept::FinalizeSubpackage(const ATMPArgs& args)
|
|||
}
|
||||
m_subpackage.m_changeset->Apply();
|
||||
m_subpackage.m_changeset.reset();
|
||||
// Don't attempt to process the same conflicts repeatedly during subpackage evaluation:
|
||||
// they no longer exist on subsequent calls to Finalize() post-Apply()
|
||||
m_subpackage.m_all_conflicts.clear();
|
||||
}
|
||||
|
||||
bool MemPoolAccept::SubmitPackage(const ATMPArgs& args, std::vector<Workspace>& workspaces,
|
||||
|
|
Loading…
Reference in a new issue