Avoid using mapTx.modify() to update modified fees

Now that the mempool no longer keeps any feerate-based indices, we can modify
feerates in mempool entries directly.
This commit is contained in:
Suhas Daftuar
2025-11-10 18:19:18 -05:00
parent d84ffc24d2
commit d2dcd37aac
2 changed files with 4 additions and 4 deletions

View File

@@ -598,7 +598,7 @@ void CTxMemPool::PrioritiseTransaction(const Txid& hash, const CAmount& nFeeDelt
if (it != mapTx.end()) {
// PrioritiseTransaction calls stack on previous ones. Set the new
// transaction fee to be current modified fee + feedelta.
mapTx.modify(it, [&nFeeDelta](CTxMemPoolEntry& e) { e.UpdateModifiedFee(nFeeDelta); });
it->UpdateModifiedFee(nFeeDelta);
m_txgraph->SetTransactionFee(*it, it->GetModifiedFee());
++nTransactionsUpdated;
}
@@ -975,7 +975,7 @@ CTxMemPool::ChangeSet::TxHandle CTxMemPool::ChangeSet::StageAddition(const CTran
TxGraph::Ref ref(m_pool->m_txgraph->AddTransaction(FeePerWeight(fee, GetSigOpsAdjustedWeight(GetTransactionWeight(*tx), sigops_cost, ::nBytesPerSigOp))));
auto newit = m_to_add.emplace(std::move(ref), tx, fee, time, entry_height, entry_sequence, spends_coinbase, sigops_cost, lp).first;
if (delta) {
m_to_add.modify(newit, [&delta](CTxMemPoolEntry& e) { e.UpdateModifiedFee(delta); });
newit->UpdateModifiedFee(delta);
m_pool->m_txgraph->SetTransactionFee(*newit, newit->GetModifiedFee());
}