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:
ismaelsadeeq
2025-11-19 16:05:25 +00:00
parent 0d88558f95
commit cfe585df25
11 changed files with 31 additions and 22 deletions

View File

@@ -156,7 +156,7 @@ void Finish(FuzzedDataProvider& fuzzed_data_provider, MockedTxPool& tx_pool, Cha
// Try updating the mempool for this block, as though it were mined.
LOCK2(::cs_main, tx_pool.cs);
tx_pool.removeForBlock(block_template->block.vtx, chainstate.m_chain.Height() + 1);
tx_pool.removeForBlock(block_template->block.vtx);
// Now try to add those transactions back, as though a reorg happened.
std::vector<Txid> hashes_to_update;