Skip to main content

ChainStateAccess

Trait ChainStateAccess 

Source
pub trait ChainStateAccess {
    // Required methods
    fn has_object(&self, hash: &Hash) -> bool;
    fn get_object(&self, hash: &Hash) -> Option<ChainObject>;
    fn get_headers_for_locator(
        &self,
        locator: &[Hash],
        stop: &Hash,
    ) -> Vec<BlockHeader>;
    fn get_mempool_transactions(&self) -> Vec<Transaction>;

    // Provided method
    fn get_block_witnesses(&self, _hash: &Hash) -> Option<Vec<Vec<Witness>>> { ... }
}
Expand description

Trait for chain state access (node layer implements this)

This trait allows the protocol layer to query chain state without owning it. The node layer provides real implementations using its storage modules (BlockStore, TxIndex, MempoolManager).

Required Methods§

Source

fn has_object(&self, hash: &Hash) -> bool

Check if we have an object (block or transaction) by hash

Source

fn get_object(&self, hash: &Hash) -> Option<ChainObject>

Get an object (block or transaction) by hash

Source

fn get_headers_for_locator( &self, locator: &[Hash], stop: &Hash, ) -> Vec<BlockHeader>

Get headers for a block locator (for GetHeaders requests) This implements the Bitcoin block locator algorithm

Source

fn get_mempool_transactions(&self) -> Vec<Transaction>

Get all mempool transactions

Provided Methods§

Source

fn get_block_witnesses(&self, _hash: &Hash) -> Option<Vec<Vec<Witness>>>

Witness stacks for a stored block (SegWit relay). Default: not available.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§