Bitcoin Core  0.20.99
P2P Digital Currency
Public Member Functions | List of all members
interfaces::Chain::Lock Class Referenceabstract

Interface for querying locked chain state, used by legacy code that assumes state won't change between calls. More...

#include <chain.h>

Public Member Functions

virtual ~Lock ()
 
virtual Optional< int > getHeight ()=0
 Get current chain height, not including genesis block (returns 0 if chain only contains genesis block, nullopt if chain does not contain any blocks). More...
 
virtual Optional< int > getBlockHeight (const uint256 &hash)=0
 Get block height above genesis block. More...
 
virtual uint256 getBlockHash (int height)=0
 Get block hash. Height must be valid or this function will abort. More...
 
virtual bool haveBlockOnDisk (int height)=0
 Check that the block is available on disk (i.e. More...
 
virtual Optional< int > findFirstBlockWithTimeAndHeight (int64_t time, int height, uint256 *hash)=0
 Return height of the first block in the chain with timestamp equal or greater than the given time and height equal or greater than the given height, or nullopt if there is no block with a high enough timestamp and height. More...
 
virtual Optional< int > findFork (const uint256 &hash, Optional< int > *height)=0
 Return height of the specified block if it is on the chain, otherwise return the height of the highest block on chain that's an ancestor of the specified block, or nullopt if there is no common ancestor. More...
 
virtual CBlockLocator getTipLocator ()=0
 Get locator for the current chain tip. More...
 
virtual Optional< int > findLocatorFork (const CBlockLocator &locator)=0
 Return height of the highest block on chain in common with the locator, which will either be the original block used to create the locator, or one of its ancestors. More...
 
virtual bool checkFinalTx (const CTransaction &tx)=0
 Check if transaction will be final given chain height current time. More...
 

Detailed Description

Interface for querying locked chain state, used by legacy code that assumes state won't change between calls.

New code should avoid using the Lock interface and instead call higher-level Chain methods that return more information so the chain doesn't need to stay locked between calls.

Definition at line 85 of file chain.h.

Constructor & Destructor Documentation

◆ ~Lock()

virtual interfaces::Chain::Lock::~Lock ( )
inlinevirtual

Definition at line 88 of file chain.h.

Here is the call graph for this function:

Member Function Documentation

◆ checkFinalTx()

virtual bool interfaces::Chain::Lock::checkFinalTx ( const CTransaction tx)
pure virtual

Check if transaction will be final given chain height current time.

Here is the caller graph for this function:

◆ findFirstBlockWithTimeAndHeight()

virtual Optional<int> interfaces::Chain::Lock::findFirstBlockWithTimeAndHeight ( int64_t  time,
int  height,
uint256 hash 
)
pure virtual

Return height of the first block in the chain with timestamp equal or greater than the given time and height equal or greater than the given height, or nullopt if there is no block with a high enough timestamp and height.

Also return the block hash as an optional output parameter (to avoid the cost of a second lookup in case this information is needed.)

◆ findFork()

virtual Optional<int> interfaces::Chain::Lock::findFork ( const uint256 hash,
Optional< int > *  height 
)
pure virtual

Return height of the specified block if it is on the chain, otherwise return the height of the highest block on chain that's an ancestor of the specified block, or nullopt if there is no common ancestor.

Also return the height of the specified block as an optional output parameter (to avoid the cost of a second hash lookup in case this information is desired).

◆ findLocatorFork()

virtual Optional<int> interfaces::Chain::Lock::findLocatorFork ( const CBlockLocator locator)
pure virtual

Return height of the highest block on chain in common with the locator, which will either be the original block used to create the locator, or one of its ancestors.

◆ getBlockHash()

virtual uint256 interfaces::Chain::Lock::getBlockHash ( int  height)
pure virtual

Get block hash. Height must be valid or this function will abort.

◆ getBlockHeight()

virtual Optional<int> interfaces::Chain::Lock::getBlockHeight ( const uint256 hash)
pure virtual

Get block height above genesis block.

Returns 0 for genesis block, 1 for following block, and so on. Returns nullopt for a block not included in the current chain.

◆ getHeight()

virtual Optional<int> interfaces::Chain::Lock::getHeight ( )
pure virtual

Get current chain height, not including genesis block (returns 0 if chain only contains genesis block, nullopt if chain does not contain any blocks).

◆ getTipLocator()

virtual CBlockLocator interfaces::Chain::Lock::getTipLocator ( )
pure virtual

Get locator for the current chain tip.

◆ haveBlockOnDisk()

virtual bool interfaces::Chain::Lock::haveBlockOnDisk ( int  height)
pure virtual

Check that the block is available on disk (i.e.

has not been pruned), and contains transactions.


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