Bitcoin
Public Member Functions | List of all members
interfaces::Chain::Lock Class Referenceabstract

#include <chain.h>

Inheritance diagram for interfaces::Chain::Lock:
interfaces::anonymous_namespace{chain.cpp}::LockImpl

Public Member Functions

virtual ~Lock ()
 
virtual Optional< int > getHeight ()=0
 
virtual Optional< int > getBlockHeight (const uint256 &hash)=0
 
virtual int getBlockDepth (const uint256 &hash)=0
 
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
 
virtual bool haveBlockOnDisk (int height)=0
 
virtual Optional< int > findFirstBlockWithTimeAndHeight (int64_t time, int height, uint256 *hash)=0
 
virtual Optional< int > findPruned (int start_height=0, Optional< int > stop_height=nullopt)=0
 
virtual Optional< int > findFork (const uint256 &hash, Optional< int > *height)=0
 
virtual CBlockLocator getTipLocator ()=0
 Get locator for the current chain tip. More...
 
virtual Optional< int > findLocatorFork (const CBlockLocator &locator)=0
 
virtual bool checkFinalTx (const CTransaction &tx)=0
 Check if transaction will be final given chain height current time. More...
 
virtual bool submitToMemoryPool (const CTransactionRef &tx, CAmount absurd_fee, CValidationState &state)=0
 

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.

Constructor & Destructor Documentation

◆ ~Lock()

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

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.

Implemented in interfaces::anonymous_namespace{chain.cpp}::LockImpl.

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

Implemented in interfaces::anonymous_namespace{chain.cpp}::LockImpl.

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

Implemented in interfaces::anonymous_namespace{chain.cpp}::LockImpl.

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

Implemented in interfaces::anonymous_namespace{chain.cpp}::LockImpl.

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

Implemented in interfaces::anonymous_namespace{chain.cpp}::LockImpl.

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

Implemented in interfaces::anonymous_namespace{chain.cpp}::LockImpl.

◆ getBlockHash()

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

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

Implemented in interfaces::anonymous_namespace{chain.cpp}::LockImpl.

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

Implemented in interfaces::anonymous_namespace{chain.cpp}::LockImpl.

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

Implemented in interfaces::anonymous_namespace{chain.cpp}::LockImpl.

◆ getBlockTime()

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

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

Implemented in interfaces::anonymous_namespace{chain.cpp}::LockImpl.

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

Implemented in interfaces::anonymous_namespace{chain.cpp}::LockImpl.

◆ getTipLocator()

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

Get locator for the current chain tip.

Implemented in interfaces::anonymous_namespace{chain.cpp}::LockImpl.

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

Implemented in interfaces::anonymous_namespace{chain.cpp}::LockImpl.

◆ submitToMemoryPool()

virtual bool interfaces::Chain::Lock::submitToMemoryPool ( const CTransactionRef tx,
CAmount  absurd_fee,
CValidationState state 
)
pure virtual

Add transaction to memory pool if the transaction fee is below the amount specified by absurd_fee. Returns false if the transaction could not be added due to the fee or for another reason.

Implemented in interfaces::anonymous_namespace{chain.cpp}::LockImpl.


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