pub struct ChainstateManager { /* private fields */ }Expand description
The chainstate manager is the central object for doing validation tasks as well as retrieving data from the chain. Internally it is a complex data structure with diverse functionality.
The chainstate manager is only valid for as long as the Context with which it
was created remains in memory.
Its functionality will be more and more exposed in the future.
Implementations§
Source§impl ChainstateManager
impl ChainstateManager
pub fn new( chainman_opts: ChainstateManagerOptions, context: Arc<Context>, ) -> Result<Self, KernelError>
Sourcepub fn process_block(&self, block: &Block) -> (bool, bool)
pub fn process_block(&self, block: &Block) -> (bool, bool)
Process and validate the passed in block with the ChainstateManager
If processing failed, some information can be retrieved through the status
enumeration. More detailed validation information in case of a failure can
also be retrieved through a registered validation interface. If the block
fails to validate the block_checked callback’s [‘BlockValidationState’] will
contain details.
Sourcepub fn import_blocks(&self) -> Result<(), KernelError>
pub fn import_blocks(&self) -> Result<(), KernelError>
May be called after load_chainstate to initialize the
ChainstateManager. Triggers the start of a reindex if the option was
previously set for the chainstate and block manager. Can also import an
array of existing block files selected by the user.
Sourcepub fn get_block_index_tip(&self) -> BlockIndex
pub fn get_block_index_tip(&self) -> BlockIndex
Get the block index entry of the current chain tip. Once returned, there is no guarantee that it remains in the active chain.
Sourcepub fn get_block_index_genesis(&self) -> BlockIndex
pub fn get_block_index_genesis(&self) -> BlockIndex
Get the block index entry of the genesis block.
Sourcepub fn get_block_index_by_height(
&self,
block_height: i32,
) -> Result<BlockIndex, KernelError>
pub fn get_block_index_by_height( &self, block_height: i32, ) -> Result<BlockIndex, KernelError>
Retrieve a block index by its height in the currently active chain. Once retrieved there is no guarantee that it remains in the active chain.
Sourcepub fn get_block_index_by_hash(
&self,
hash: BlockHash,
) -> Result<BlockIndex, KernelError>
pub fn get_block_index_by_hash( &self, hash: BlockHash, ) -> Result<BlockIndex, KernelError>
Get a block index entry by its hash.
Sourcepub fn get_next_block_index(
&self,
block_index: BlockIndex,
) -> Result<BlockIndex, KernelError>
pub fn get_next_block_index( &self, block_index: BlockIndex, ) -> Result<BlockIndex, KernelError>
Get the next block index entry in the chain. If this is the tip, or otherwise a leaf in the block tree, return an error.
Sourcepub fn read_block_data(
&self,
block_index: &BlockIndex,
) -> Result<Block, KernelError>
pub fn read_block_data( &self, block_index: &BlockIndex, ) -> Result<Block, KernelError>
Read a block from disk by its block index.
Sourcepub fn read_undo_data(
&self,
block_index: &BlockIndex,
) -> Result<BlockUndo, KernelError>
pub fn read_undo_data( &self, block_index: &BlockIndex, ) -> Result<BlockUndo, KernelError>
Read a block’s undo data from disk by its block index.