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>;
}
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

Implementors§