From 46e3efd1e4ae2f058ecfffdaee7e882c4305eb35 Mon Sep 17 00:00:00 2001 From: James O'Beirne Date: Fri, 9 Jul 2021 13:06:19 -0400 Subject: refactor: move UpdateMempoolForReorg into CChainState Allows fewer arguments and simplification of call sites. Co-authored-by: John Newbery --- src/validation.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/validation.h') diff --git a/src/validation.h b/src/validation.h index 4823505cfc..68616f036a 100644 --- a/src/validation.h +++ b/src/validation.h @@ -808,6 +808,23 @@ private: return m_mempool ? &m_mempool->cs : nullptr; } + /** + * Make mempool consistent after a reorg, by re-adding or recursively erasing + * disconnected block transactions from the mempool, and also removing any + * other transactions from the mempool that are no longer valid given the new + * tip/height. + * + * Note: we assume that disconnectpool only contains transactions that are NOT + * confirmed in the current chain nor already in the mempool (otherwise, + * in-mempool descendants of such transactions would be removed). + * + * Passing fAddToMempool=false will skip trying to add the transactions back, + * and instead just erase from the mempool as needed. + */ + void MaybeUpdateMempoolForReorg( + DisconnectedBlockTransactions& disconnectpool, + bool fAddToMempool) EXCLUSIVE_LOCKS_REQUIRED(cs_main, m_mempool->cs); + friend ChainstateManager; }; -- cgit v1.2.3