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 methods
    fn get_block_witnesses(&self, _hash: &Hash) -> Option<Vec<Vec<Witness>>> { ... }
    fn ban_entries(&self) -> Vec<BanEntry> { ... }
    fn apply_ban(&self, entry: &BanEntry) -> Result<(), String> { ... }
    fn stored_utxo_commitment(
        &self,
        _block_hash: &Hash,
    ) -> Result<Option<UTXOCommitment>, String> { ... }
    fn stored_block_filter(
        &self,
        _block_hash: &Hash,
    ) -> Result<Option<(BlockHeader, Vec<u8>)>, String> { ... }
}
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.

Source

fn ban_entries(&self) -> Vec<BanEntry>

Ban entries this node would return from getbanlist. Default: none stored.

Source

fn apply_ban(&self, entry: &BanEntry) -> Result<(), String>

Apply one ban the way setban does: the address is the IP with port 0, and timestamp is the absolute unban time (0 is permanent).

Source

fn stored_utxo_commitment( &self, _block_hash: &Hash, ) -> Result<Option<UTXOCommitment>, String>

Stored UTXO commitment for a block, when this node has one.

Source

fn stored_block_filter( &self, _block_hash: &Hash, ) -> Result<Option<(BlockHeader, Vec<u8>)>, String>

Basic block filter for a block, the bytes getblockfilter already builds.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§