Bitcoin
Protected Member Functions | List of all members
CValidationInterface Class Reference

#include <validationinterface.h>

Inheritance diagram for CValidationInterface:
BaseIndex CZMQNotificationInterface interfaces::anonymous_namespace{chain.cpp}::NotificationsHandlerImpl PeerLogicValidation submitblock_StateCatcher BlockFilterIndex TxIndex

Protected Member Functions

 ~CValidationInterface ()=default
 
virtual void UpdatedBlockTip (const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload)
 
virtual void TransactionAddedToMempool (const CTransactionRef &ptxn)
 
virtual void TransactionRemovedFromMempool (const CTransactionRef &ptx)
 
virtual void BlockConnected (const std::shared_ptr< const CBlock > &block, const CBlockIndex *pindex, const std::vector< CTransactionRef > &txnConflicted)
 
virtual void BlockDisconnected (const std::shared_ptr< const CBlock > &block)
 
virtual void ChainStateFlushed (const CBlockLocator &locator)
 
virtual void BlockChecked (const CBlock &, const CValidationState &)
 
virtual void NewPoWValidBlock (const CBlockIndex *pindex, const std::shared_ptr< const CBlock > &block)
 
friend void ::RegisterValidationInterface (CValidationInterface *)
 
friend void ::UnregisterValidationInterface (CValidationInterface *)
 
friend void ::UnregisterAllValidationInterfaces ()
 

Detailed Description

Implement this to subscribe to events generated in validation

Each CValidationInterface() subscriber will receive event callbacks in the order in which the events were generated by validation. 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.

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

◆ BlockChecked()

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

Notifies listeners of a block validation result. If the provided CValidationState IsValid, the provided block is guaranteed to be the current best block at the time the callback was generated (not necessarily now)

Reimplemented in submitblock_StateCatcher, and PeerLogicValidation.

◆ BlockConnected()

virtual void CValidationInterface::BlockConnected ( const std::shared_ptr< const CBlock > &  block,
const CBlockIndex pindex,
const std::vector< CTransactionRef > &  txnConflicted 
)
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 interfaces::anonymous_namespace{chain.cpp}::NotificationsHandlerImpl, BaseIndex, PeerLogicValidation, and CZMQNotificationInterface.

◆ BlockDisconnected()

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

Notifies listeners of a block being disconnected

Called on a background thread.

Reimplemented in interfaces::anonymous_namespace{chain.cpp}::NotificationsHandlerImpl, and CZMQNotificationInterface.

◆ ChainStateFlushed()

virtual void CValidationInterface::ChainStateFlushed ( 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 interfaces::anonymous_namespace{chain.cpp}::NotificationsHandlerImpl, and BaseIndex.

◆ 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

Reimplemented in PeerLogicValidation.

◆ TransactionAddedToMempool()

virtual void CValidationInterface::TransactionAddedToMempool ( const CTransactionRef ptxn)
inlineprotectedvirtual

Notifies listeners of a transaction having been added to mempool.

Called on a background thread.

Reimplemented in interfaces::anonymous_namespace{chain.cpp}::NotificationsHandlerImpl, and CZMQNotificationInterface.

◆ TransactionRemovedFromMempool()

virtual void CValidationInterface::TransactionRemovedFromMempool ( const CTransactionRef ptx)
inlineprotectedvirtual

Notifies listeners of a transaction leaving mempool.

This only fires for transactions which leave mempool because of expiry, size limiting, reorg (changes in lock times/coinbase maturity), or replacement. This does not include any transactions which are included in BlockConnectedDisconnected either in block->vtx or in txnConflicted.

Called on a background thread.

Reimplemented in interfaces::anonymous_namespace{chain.cpp}::NotificationsHandlerImpl.

◆ 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.

Reimplemented in interfaces::anonymous_namespace{chain.cpp}::NotificationsHandlerImpl, PeerLogicValidation, and CZMQNotificationInterface.

◆ void ::RegisterValidationInterface()

CValidationInterface::void ::RegisterValidationInterface ( CValidationInterface )
protected

◆ void ::UnregisterAllValidationInterfaces()

CValidationInterface::void ::UnregisterAllValidationInterfaces ( )
protected

◆ void ::UnregisterValidationInterface()

CValidationInterface::void ::UnregisterValidationInterface ( CValidationInterface )
protected

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