add ValidationInterface::ActiveTipChange

This is a synchronous callback notifying clients of all tip changes.

It allows clients to respond to a new block immediately after it is
connected. The synchronicity is important for things like
m_recent_rejects, in which a transaction's validity can change (rejected
vs accepted) when this event is processed. For example, the transaction
might have a timelock condition that has just been met. This is distinct
from something like m_recent_confirmed_transactions, in which the
validation outcome is the same (valid vs already-have), so it does not
need to be reset immediately.
This commit is contained in:
glozow
2023-09-29 13:58:16 +01:00
parent 3eb1307df0
commit 36f170d879
3 changed files with 24 additions and 1 deletions

View File

@@ -61,6 +61,10 @@ protected:
* Called on a background thread. Only called for the active chainstate.
*/
virtual void UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload) {}
/**
* Notifies listeners any time the block chain tip changes, synchronously.
*/
virtual void ActiveTipChange(const CBlockIndex* new_tip, bool is_ibd) {};
/**
* Notifies listeners of a transaction having been added to mempool.
*
@@ -214,6 +218,7 @@ public:
void SyncWithValidationInterfaceQueue() LOCKS_EXCLUDED(cs_main);
void UpdatedBlockTip(const CBlockIndex *, const CBlockIndex *, bool fInitialDownload);
void ActiveTipChange(const CBlockIndex*, bool);
void TransactionAddedToMempool(const NewMempoolTransactionInfo&, uint64_t mempool_sequence);
void TransactionRemovedFromMempool(const CTransactionRef&, MemPoolRemovalReason, uint64_t mempool_sequence);
void MempoolTransactionsRemovedForBlock(const std::vector<RemovedMempoolTransactionInfo>&, unsigned int nBlockHeight);