ProvidesUnvalidatedBlockchain

Trait ProvidesUnvalidatedBlockchain 

Source
pub trait ProvidesUnvalidatedBlockchain: Sync + ProvidesBlockchainMeta {
    // Required methods
    fn block(
        &self,
        hash: [u8; 32],
    ) -> impl Send + Future<Output = Result<Block, InterfaceError>>;
    fn block_hash(
        &self,
        number: usize,
    ) -> impl Send + Future<Output = Result<[u8; 32], InterfaceError>>;

    // Provided methods
    fn contiguous_blocks(
        &self,
        range: RangeInclusive<usize>,
    ) -> impl Send + Future<Output = Result<Vec<Block>, InterfaceError>> { ... }
    fn block_by_number(
        &self,
        number: usize,
    ) -> impl Send + Future<Output = Result<Block, InterfaceError>> { ... }
}
Expand description

Provides the blockchain from an untrusted interface.

This provides some of its methods yet (contiguous_blocks || block_by_number) MUST be overriden, and the batch method SHOULD be overriden.

Required Methods§

Source

fn block( &self, hash: [u8; 32], ) -> impl Send + Future<Output = Result<Block, InterfaceError>>

Get a block by its hash.

No validation is applied to the received block other than that it deserializes.

Source

fn block_hash( &self, number: usize, ) -> impl Send + Future<Output = Result<[u8; 32], InterfaceError>>

Get the hash of a block by its number.

The number of a block is its index on the blockchain, so the genesis block would have number = 0.

Provided Methods§

Source

fn contiguous_blocks( &self, range: RangeInclusive<usize>, ) -> impl Send + Future<Output = Result<Vec<Block>, InterfaceError>>

Get a contiguous range of blocks.

No validation is applied to the received blocks other than that they deserialize and have the expected length.

Source

fn block_by_number( &self, number: usize, ) -> impl Send + Future<Output = Result<Block, InterfaceError>>

Get a block by its number.

The number of a block is its index on the blockchain, so the genesis block would have number = 0.

No validation is applied to the received blocks other than that it deserializes.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§