Bitcoin Core  0.18.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 int getBlockDepth (const uint256 &hash)=0
 Get block depth. More...
 
virtual uint256 getBlockHash (int height)=0
 Get block hash. Height must be valid or this function will abort. More...
 
virtual int64_t getBlockTime (int height)=0
 Get block time. Height must be valid or this function will abort. More...
 
virtual int64_t getBlockMedianTimePast (int height)=0
 Get block median time past. 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 > findPruned (int start_height=0, Optional< int > stop_height=nullopt)=0
 Return height of last block in the specified range which is pruned, or nullopt if no block in the range is pruned. 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 64 of file chain.h.

Constructor & Destructor Documentation

◆ ~Lock()

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

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

Here is the caller graph for this function:

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

Here is the caller graph for this function:

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

Here is the caller graph for this function:

◆ findPruned()

virtual Optional<int> interfaces::Chain::Lock::findPruned ( int  start_height = 0,
Optional< int >  stop_height = nullopt 
)
pure virtual

Return height of last block in the specified range which is pruned, or nullopt if no block in the range is pruned.

Range is inclusive.

Here is the caller graph for this function:

◆ getBlockDepth()

virtual int interfaces::Chain::Lock::getBlockDepth ( const uint256 hash)
pure virtual

Get block depth.

Returns 1 for chain tip, 2 for preceding block, and so on. Returns 0 for a block not included in the current chain.

Here is the caller graph for this function:

◆ getBlockHash()

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

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

Here is the caller graph for this function:

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

Here is the caller graph for this function:

◆ getBlockMedianTimePast()

virtual int64_t interfaces::Chain::Lock::getBlockMedianTimePast ( int  height)
pure virtual

Get block median time past.

Height must be valid or this function will abort.

Here is the caller graph for this function:

◆ getBlockTime()

virtual int64_t interfaces::Chain::Lock::getBlockTime ( int  height)
pure virtual

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

Here is the caller graph for this function:

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

Here is the caller graph for this function:

◆ getTipLocator()

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

Get locator for the current chain tip.

Here is the caller graph for this function:

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

Here is the caller graph for this function:

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