Changeset View
Changeset View
Standalone View
Standalone View
src/interfaces/chain.h
Show First 20 Lines • Show All 102 Lines • ▼ Show 20 Lines | public: | ||||
//! assumes state won't change between calls. New code should avoid using | //! assumes state won't change between calls. New code should avoid using | ||||
//! the Lock interface and instead call higher-level Chain methods | //! the Lock interface and instead call higher-level Chain methods | ||||
//! that return more information so the chain doesn't need to stay locked | //! that return more information so the chain doesn't need to stay locked | ||||
//! between calls. | //! between calls. | ||||
class Lock { | class Lock { | ||||
public: | public: | ||||
virtual ~Lock() {} | virtual ~Lock() {} | ||||
//! Get block hash. Height must be valid or this function will abort. | |||||
virtual BlockHash getBlockHash(int height) = 0; | |||||
//! Check that the block is available on disk (i.e. has not been | //! Check that the block is available on disk (i.e. has not been | ||||
//! pruned), and contains transactions. | //! pruned), and contains transactions. | ||||
virtual bool haveBlockOnDisk(int height) = 0; | virtual bool haveBlockOnDisk(int height) = 0; | ||||
//! Return height of the first block in the chain with timestamp equal | //! 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 | //! 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 | //! given height, or nullopt if there is no block with a high enough | ||||
//! timestamp and height. Also return the block hash as an optional | //! timestamp and height. Also return the block hash as an optional | ||||
Show All 34 Lines | public: | ||||
//! any blocks) | //! any blocks) | ||||
virtual Optional<int> getHeight() = 0; | virtual Optional<int> getHeight() = 0; | ||||
//! Get block height above genesis block. Returns 0 for genesis block, | //! Get block height above genesis block. Returns 0 for genesis block, | ||||
//! 1 for following block, and so on. Returns nullopt for a block not | //! 1 for following block, and so on. Returns nullopt for a block not | ||||
//! included in the current chain. | //! included in the current chain. | ||||
virtual Optional<int> getBlockHeight(const BlockHash &hash) = 0; | virtual Optional<int> getBlockHeight(const BlockHash &hash) = 0; | ||||
//! Get block hash. Height must be valid or this function will abort. | |||||
virtual BlockHash getBlockHash(int height) = 0; | |||||
//! Return whether node has the block and optionally return block metadata | //! Return whether node has the block and optionally return block metadata | ||||
//! or contents. | //! or contents. | ||||
virtual bool findBlock(const BlockHash &hash, | virtual bool findBlock(const BlockHash &hash, | ||||
const FoundBlock &block = {}) = 0; | const FoundBlock &block = {}) = 0; | ||||
//! Find first block in the chain with timestamp >= the given time | //! Find first block in the chain with timestamp >= the given time | ||||
//! and height >= than the given height, return false if there is no block | //! and height >= than the given height, return false if there is no block | ||||
//! with a high enough timestamp and height. Optionally return block | //! with a high enough timestamp and height. Optionally return block | ||||
▲ Show 20 Lines • Show All 203 Lines • Show Last 20 Lines |