pub trait ProvidesBlockchain: ProvidesBlockchainMeta {
// Required methods
fn contiguous_blocks(
&self,
range: RangeInclusive<usize>,
) -> impl Send + Future<Output = Result<Vec<Block>, InterfaceError>>;
fn block(
&self,
hash: [u8; 32],
) -> impl Send + Future<Output = Result<Block, InterfaceError>>;
fn block_by_number(
&self,
number: usize,
) -> impl Send + Future<Output = Result<Block, InterfaceError>>;
fn block_hash(
&self,
number: usize,
) -> impl Send + Future<Output = Result<[u8; 32], InterfaceError>>;
}Expand description
Provides blocks which have been sanity-checked.
Required Methods§
Sourcefn contiguous_blocks(
&self,
range: RangeInclusive<usize>,
) -> impl Send + Future<Output = Result<Vec<Block>, InterfaceError>>
fn contiguous_blocks( &self, range: RangeInclusive<usize>, ) -> impl Send + Future<Output = Result<Vec<Block>, InterfaceError>>
Get a contiguous range of blocks.
The blocks will be validated to build upon each other, as expected, and have the expected numbers.
Sourcefn block(
&self,
hash: [u8; 32],
) -> impl Send + Future<Output = Result<Block, InterfaceError>>
fn block( &self, hash: [u8; 32], ) -> impl Send + Future<Output = Result<Block, InterfaceError>>
Get a block by its hash.
The block will be validated to be the requested block.
Sourcefn block_by_number(
&self,
number: usize,
) -> impl Send + Future<Output = Result<Block, InterfaceError>>
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.
The block will be validated to be a block with the requested number.
Sourcefn block_hash(
&self,
number: usize,
) -> impl Send + Future<Output = Result<[u8; 32], InterfaceError>>
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.
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.