mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-09-13 06:04:42 +02:00
validation: emit block mempool removal signal from ConnectTip
Return the removed mempool transaction info from CTxMemPool::removeForBlock instead of dispatching the MempoolTransactionsRemovedForBlock notification from the mempool. Emit it from ConnectTip after mempool removal and before BlockConnected, passing the connected block, the removed mempool transactions, and the block height to the callback. Because the signal now originates from ConnectTip, where the IBD state is known, gate it on !IsInitialBlockDownload(): the notification is no longer fired for blocks connected during initial block download or reindex, while the mempool removal in removeForBlock still runs unconditionally. This keeps fee rate estimators from recording blocks connected before the node is synced.
This commit is contained in:
@@ -402,7 +402,7 @@ void CTxMemPool::removeConflicts(const CTransaction &tx)
|
||||
}
|
||||
}
|
||||
|
||||
void CTxMemPool::removeForBlock(const std::vector<CTransactionRef>& vtx, unsigned int nBlockHeight)
|
||||
std::vector<RemovedMempoolTransactionInfo> CTxMemPool::removeForBlock(const std::vector<CTransactionRef>& vtx)
|
||||
{
|
||||
// Remove confirmed txs and conflicts when a new block is connected, updating the fee logic
|
||||
AssertLockHeld(cs);
|
||||
@@ -420,14 +420,12 @@ void CTxMemPool::removeForBlock(const std::vector<CTransactionRef>& vtx, unsigne
|
||||
ClearPrioritisation(tx->GetHash());
|
||||
}
|
||||
}
|
||||
if (m_opts.signals) {
|
||||
m_opts.signals->MempoolTransactionsRemovedForBlock(txs_removed_for_block, nBlockHeight);
|
||||
}
|
||||
lastRollingFeeUpdate = GetTime();
|
||||
blockSinceLastRollingFeeBump = true;
|
||||
if (!m_txgraph->DoWork(/*max_cost=*/POST_CHANGE_COST)) {
|
||||
LogDebug(BCLog::MEMPOOL, "Mempool in non-optimal ordering after block.");
|
||||
}
|
||||
return txs_removed_for_block;
|
||||
}
|
||||
|
||||
void CTxMemPool::check(const CCoinsViewCache& active_coins_tip, int64_t spendheight) const
|
||||
|
||||
Reference in New Issue
Block a user