Bitcoin Core 28.99.0
P2P Digital Currency
Protected Member Functions | Friends | List of all members
CValidationInterface Class Reference

Implement this to subscribe to events generated in validation and mempool. More...

#include <validationinterface.h>

Inheritance diagram for CValidationInterface:
[legend]

Protected Member Functions

 ~CValidationInterface ()=default
 Protected destructor so that instances can only be deleted by derived classes. More...
 
virtual void UpdatedBlockTip (const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload)
 Notifies listeners when the block chain tip advances. More...
 
virtual void ActiveTipChange (const CBlockIndex &new_tip, bool is_ibd)
 Notifies listeners any time the block chain tip changes, synchronously. More...
 
virtual void TransactionAddedToMempool (const NewMempoolTransactionInfo &tx, uint64_t mempool_sequence)
 Notifies listeners of a transaction having been added to mempool. More...
 
virtual void TransactionRemovedFromMempool (const CTransactionRef &tx, MemPoolRemovalReason reason, uint64_t mempool_sequence)
 Notifies listeners of a transaction leaving mempool. More...
 
virtual void MempoolTransactionsRemovedForBlock (const std::vector< RemovedMempoolTransactionInfo > &txs_removed_for_block, unsigned int nBlockHeight)
 
virtual void BlockConnected (ChainstateRole role, const std::shared_ptr< const CBlock > &block, const CBlockIndex *pindex)
 Notifies listeners of a block being connected. More...
 
virtual void BlockDisconnected (const std::shared_ptr< const CBlock > &block, const CBlockIndex *pindex)
 Notifies listeners of a block being disconnected Provides the block that was disconnected. More...
 
virtual void ChainStateFlushed (ChainstateRole role, const CBlockLocator &locator)
 Notifies listeners of the new active block chain on-disk. More...
 
virtual void BlockChecked (const CBlock &, const BlockValidationState &)
 Notifies listeners of a block validation result. More...
 
virtual void NewPoWValidBlock (const CBlockIndex *pindex, const std::shared_ptr< const CBlock > &block)
 Notifies listeners that a block which builds directly on our current tip has been received and connected to the headers tree, though not validated yet. More...
 

Friends

class ValidationSignals
 
class ValidationInterfaceTest
 

Detailed Description

Implement this to subscribe to events generated in validation and mempool.

Each CValidationInterface() subscriber will receive event callbacks in the order in which the events were generated by validation and mempool. Furthermore, each ValidationInterface() subscriber may assume that callbacks effectively run in a single thread with single-threaded memory consistency. That is, for a given ValidationInterface() instantiation, each callback will complete before the next one is invoked. This means, for example when a block is connected that the UpdatedBlockTip() callback may depend on an operation performed in the BlockConnected() callback without worrying about explicit synchronization. No ordering should be assumed across ValidationInterface() subscribers.

Definition at line 47 of file validationinterface.h.

Constructor & Destructor Documentation

◆ ~CValidationInterface()

CValidationInterface::~CValidationInterface ( )
protecteddefault

Protected destructor so that instances can only be deleted by derived classes.

If that restriction is no longer desired, this should be made public and virtual.

Member Function Documentation

◆ ActiveTipChange()

virtual void CValidationInterface::ActiveTipChange ( const CBlockIndex new_tip,
bool  is_ibd 
)
inlineprotectedvirtual

Notifies listeners any time the block chain tip changes, synchronously.

Definition at line 67 of file validationinterface.h.

Here is the caller graph for this function:

◆ BlockChecked()

virtual void CValidationInterface::BlockChecked ( const CBlock ,
const BlockValidationState  
)
inlineprotectedvirtual

Notifies listeners of a block validation result.

If the provided BlockValidationState IsValid, the provided block is guaranteed to be the current best block at the time the callback was generated (not necessarily now).

Reimplemented in TestSubscriberNoop, BlockValidationStateCatcher, TestInterface, and submitblock_StateCatcher.

Definition at line 154 of file validationinterface.h.

Here is the caller graph for this function:

◆ BlockConnected()

virtual void CValidationInterface::BlockConnected ( ChainstateRole  role,
const std::shared_ptr< const CBlock > &  block,
const CBlockIndex pindex 
)
inlineprotectedvirtual

Notifies listeners of a block being connected.

Provides a vector of transactions evicted from the mempool as a result.

Called on a background thread.

Reimplemented in BaseIndex, TestSubscriber, and CZMQNotificationInterface.

Definition at line 122 of file validationinterface.h.

Here is the caller graph for this function:

◆ BlockDisconnected()

virtual void CValidationInterface::BlockDisconnected ( const std::shared_ptr< const CBlock > &  block,
const CBlockIndex pindex 
)
inlineprotectedvirtual

Notifies listeners of a block being disconnected Provides the block that was disconnected.

Called on a background thread. Only called for the active chainstate, since background chainstates should never disconnect blocks.

Reimplemented in TestSubscriber, and CZMQNotificationInterface.

Definition at line 130 of file validationinterface.h.

Here is the caller graph for this function:

◆ ChainStateFlushed()

virtual void CValidationInterface::ChainStateFlushed ( ChainstateRole  role,
const CBlockLocator locator 
)
inlineprotectedvirtual

Notifies listeners of the new active block chain on-disk.

Prior to this callback, any updates are not guaranteed to persist on disk (ie clients need to handle shutdown/restart safety by being able to understand when some updates were lost due to unclean shutdown).

When this callback is invoked, the validation changes done by any prior callback are guaranteed to exist on disk and survive a restart, including an unclean shutdown.

Provides a locator describing the best chain, which is likely useful for storing current state on disk in client DBs.

Called on a background thread.

Reimplemented in BaseIndex.

Definition at line 147 of file validationinterface.h.

Here is the caller graph for this function:

◆ MempoolTransactionsRemovedForBlock()

virtual void CValidationInterface::MempoolTransactionsRemovedForBlock ( const std::vector< RemovedMempoolTransactionInfo > &  txs_removed_for_block,
unsigned int  nBlockHeight 
)
inlineprotectedvirtual

Reimplemented in CBlockPolicyEstimator.

Definition at line 115 of file validationinterface.h.

Here is the caller graph for this function:

◆ NewPoWValidBlock()

virtual void CValidationInterface::NewPoWValidBlock ( const CBlockIndex pindex,
const std::shared_ptr< const CBlock > &  block 
)
inlineprotectedvirtual

Notifies listeners that a block which builds directly on our current tip has been received and connected to the headers tree, though not validated yet.

Definition at line 159 of file validationinterface.h.

Here is the caller graph for this function:

◆ TransactionAddedToMempool()

virtual void CValidationInterface::TransactionAddedToMempool ( const NewMempoolTransactionInfo tx,
uint64_t  mempool_sequence 
)
inlineprotectedvirtual

Notifies listeners of a transaction having been added to mempool.

Called on a background thread.

Reimplemented in CZMQNotificationInterface, and CBlockPolicyEstimator.

Definition at line 73 of file validationinterface.h.

Here is the caller graph for this function:

◆ TransactionRemovedFromMempool()

virtual void CValidationInterface::TransactionRemovedFromMempool ( const CTransactionRef tx,
MemPoolRemovalReason  reason,
uint64_t  mempool_sequence 
)
inlineprotectedvirtual

Notifies listeners of a transaction leaving mempool.

This notification fires for transactions that are removed from the mempool for the following reasons:

  • EXPIRY (expired from mempool after -mempoolexpiry hours)
  • SIZELIMIT (removed in size limiting if the mempool exceeds -maxmempool megabytes)
  • REORG (removed during a reorg)
  • CONFLICT (removed because it conflicts with in-block transaction)
  • REPLACED (removed due to RBF replacement)

This does not fire for transactions that are removed from the mempool because they have been included in a block. Any client that is interested in transactions removed from the mempool for inclusion in a block can learn about those transactions from the MempoolTransactionsRemovedForBlock notification.

Transactions that are removed from the mempool because they conflict with a transaction in the new block will have TransactionRemovedFromMempool events fired before the BlockConnected event is fired. If multiple blocks are connected in one step, then the ordering could be:

  • TransactionRemovedFromMempool(tx1 from block A)
  • TransactionRemovedFromMempool(tx2 from block A)
  • TransactionRemovedFromMempool(tx1 from block B)
  • TransactionRemovedFromMempool(tx2 from block B)
  • BlockConnected(A)
  • BlockConnected(B)

Called on a background thread.

Reimplemented in CZMQNotificationInterface, and CBlockPolicyEstimator.

Definition at line 107 of file validationinterface.h.

Here is the caller graph for this function:

◆ UpdatedBlockTip()

virtual void CValidationInterface::UpdatedBlockTip ( const CBlockIndex pindexNew,
const CBlockIndex pindexFork,
bool  fInitialDownload 
)
inlineprotectedvirtual

Notifies listeners when the block chain tip advances.

When multiple blocks are connected at once, UpdatedBlockTip will be called on the final tip but may not be called on every intermediate tip. If the latter behavior is desired, subscribe to BlockConnected() instead.

Called on a background thread. Only called for the active chainstate.

Reimplemented in TestSubscriber, and CZMQNotificationInterface.

Definition at line 63 of file validationinterface.h.

Here is the caller graph for this function:

Friends And Related Function Documentation

◆ ValidationInterfaceTest

friend class ValidationInterfaceTest
friend

Definition at line 161 of file validationinterface.h.

◆ ValidationSignals

friend class ValidationSignals
friend

Definition at line 160 of file validationinterface.h.


The documentation for this class was generated from the following file: