Struct ChainstateManager

Source
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

Source

pub fn new( chainman_opts: ChainstateManagerOptions, context: Arc<Context>, ) -> Result<Self, KernelError>

Source

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.

Source

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.

Source

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.

Source

pub fn get_block_index_genesis(&self) -> BlockIndex

Get the block index entry of the genesis block.

Source

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.

Source

pub fn get_block_index_by_hash( &self, hash: BlockHash, ) -> Result<BlockIndex, KernelError>

Get a block index entry by its hash.

Source

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.

Source

pub fn read_block_data( &self, block_index: &BlockIndex, ) -> Result<Block, KernelError>

Read a block from disk by its block index.

Source

pub fn read_undo_data( &self, block_index: &BlockIndex, ) -> Result<BlockUndo, KernelError>

Read a block’s undo data from disk by its block index.

Trait Implementations§

Source§

impl Drop for ChainstateManager

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Send for ChainstateManager

Source§

impl Sync for ChainstateManager

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.