Bitcoin ABC 0.26.3
P2P Digital Currency
Loading...
Searching...
No Matches
Protected Member Functions | Friends | List of all members
CValidationInterface Class Reference

Implement this to subscribe to events generated in validation. 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.
 
virtual void UpdatedBlockTip (const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload)
 Notifies listeners when the block chain tip advances.
 
virtual void TransactionAddedToMempool (const CTransactionRef &tx, std::shared_ptr< const std::vector< Coin > > spent_coins, uint64_t mempool_sequence)
 Notifies listeners of a transaction having been added to mempool.
 
virtual void TransactionRemovedFromMempool (const CTransactionRef &tx, MemPoolRemovalReason reason, uint64_t mempool_sequence)
 Notifies listeners of a transaction leaving mempool.
 
virtual void BlockConnected (const std::shared_ptr< const CBlock > &block, const CBlockIndex *pindex)
 Notifies listeners of a block being connected.
 
virtual void BlockDisconnected (const std::shared_ptr< const CBlock > &block, const CBlockIndex *pindex)
 Notifies listeners of a block being disconnected.
 
virtual void ChainStateFlushed (const CBlockLocator &locator)
 Notifies listeners of the new active block chain on-disk.
 
virtual void BlockChecked (const CBlock &, const BlockValidationState &)
 Notifies listeners of a block validation result.
 
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.
 
virtual void BlockFinalized (const CBlockIndex *pindex)
 
virtual void BlockInvalidated (const CBlockIndex *pindex, const std::shared_ptr< const CBlock > &block)
 

Friends

class CMainSignals
 
class ValidationInterfaceTest
 

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.

Definition at line 82 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

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

Definition at line 185 of file validationinterface.h.

Here is the caller graph for this function:

◆ BlockConnected()

virtual void CValidationInterface::BlockConnected ( 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, and CZMQNotificationInterface.

Definition at line 153 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.

Called on a background thread.

Reimplemented in CZMQNotificationInterface.

Definition at line 160 of file validationinterface.h.

Here is the caller graph for this function:

◆ BlockFinalized()

virtual void CValidationInterface::BlockFinalized ( const CBlockIndex pindex)
inlineprotectedvirtual

Definition at line 194 of file validationinterface.h.

Here is the caller graph for this function:

◆ BlockInvalidated()

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

Definition at line 195 of file validationinterface.h.

Here is the caller graph for this function:

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

Definition at line 178 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 191 of file validationinterface.h.

Here is the caller graph for this function:

◆ TransactionAddedToMempool()

virtual void CValidationInterface::TransactionAddedToMempool ( const CTransactionRef tx,
std::shared_ptr< const std::vector< Coin > >  spent_coins,
uint64_t  mempool_sequence 
)
inlineprotectedvirtual

Notifies listeners of a transaction having been added to mempool.

Called on a background thread.

Reimplemented in CZMQNotificationInterface.

Definition at line 107 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)

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

Definition at line 144 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.

Reimplemented in CZMQNotificationInterface.

Definition at line 99 of file validationinterface.h.

Here is the caller graph for this function:

Friends And Related Symbol Documentation

◆ CMainSignals

Definition at line 198 of file validationinterface.h.

◆ ValidationInterfaceTest

friend class ValidationInterfaceTest
friend

Definition at line 199 of file validationinterface.h.


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