mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-31 10:41:08 +00:00
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:
parent
d84ffc24d2
commit
d2dcd37aac
@ -80,7 +80,7 @@ private:
|
||||
const unsigned int entryHeight; //!< Chain height when entering the mempool
|
||||
const bool spendsCoinbase; //!< keep track of transactions that spend a coinbase
|
||||
const int64_t sigOpCost; //!< Total sigop cost
|
||||
CAmount m_modified_fee; //!< Used for determining the priority of the transaction for mining in a block
|
||||
mutable CAmount m_modified_fee; //!< Used for determining the priority of the transaction for mining in a block
|
||||
mutable LockPoints lockPoints; //!< Track the height and time at which tx was final
|
||||
|
||||
public:
|
||||
@ -124,7 +124,7 @@ public:
|
||||
const LockPoints& GetLockPoints() const { return lockPoints; }
|
||||
|
||||
// Updates the modified fees with descendants/ancestors.
|
||||
void UpdateModifiedFee(CAmount fee_diff)
|
||||
void UpdateModifiedFee(CAmount fee_diff) const
|
||||
{
|
||||
m_modified_fee = SaturatingAdd(m_modified_fee, fee_diff);
|
||||
}
|
||||
|
||||
@ -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());
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user