Trait polkadot_service::HeaderBackend

source ·
pub trait HeaderBackend<Block>: Send + Sync
where Block: Block,
{ // Required methods fn header( &self, hash: <Block as Block>::Hash, ) -> Result<Option<<Block as Block>::Header>, Error>; fn info(&self) -> Info<Block>; fn status(&self, hash: <Block as Block>::Hash) -> Result<BlockStatus, Error>; fn number( &self, hash: <Block as Block>::Hash, ) -> Result<Option<<<Block as Block>::Header as Header>::Number>, Error>; fn hash( &self, number: <<Block as Block>::Header as Header>::Number, ) -> Result<Option<<Block as Block>::Hash>, Error>; // Provided methods fn block_hash_from_id( &self, id: &BlockId<Block>, ) -> Result<Option<<Block as Block>::Hash>, Error> { ... } fn block_number_from_id( &self, id: &BlockId<Block>, ) -> Result<Option<<<Block as Block>::Header as Header>::Number>, Error> { ... } fn expect_header( &self, hash: <Block as Block>::Hash, ) -> Result<<Block as Block>::Header, Error> { ... } fn expect_block_number_from_id( &self, id: &BlockId<Block>, ) -> Result<<<Block as Block>::Header as Header>::Number, Error> { ... } fn expect_block_hash_from_id( &self, id: &BlockId<Block>, ) -> Result<<Block as Block>::Hash, Error> { ... } }
Expand description

Blockchain database header backend. Does not perform any validation.

Required Methods§

source

fn header( &self, hash: <Block as Block>::Hash, ) -> Result<Option<<Block as Block>::Header>, Error>

Get block header. Returns None if block is not found.

source

fn info(&self) -> Info<Block>

Get blockchain info.

source

fn status(&self, hash: <Block as Block>::Hash) -> Result<BlockStatus, Error>

Get block status.

source

fn number( &self, hash: <Block as Block>::Hash, ) -> Result<Option<<<Block as Block>::Header as Header>::Number>, Error>

Get block number by hash. Returns None if the header is not in the chain.

source

fn hash( &self, number: <<Block as Block>::Header as Header>::Number, ) -> Result<Option<<Block as Block>::Hash>, Error>

Get block hash by number. Returns None if the header is not in the chain.

Provided Methods§

source

fn block_hash_from_id( &self, id: &BlockId<Block>, ) -> Result<Option<<Block as Block>::Hash>, Error>

Convert an arbitrary block ID into a block hash.

source

fn block_number_from_id( &self, id: &BlockId<Block>, ) -> Result<Option<<<Block as Block>::Header as Header>::Number>, Error>

Convert an arbitrary block ID into a block hash.

source

fn expect_header( &self, hash: <Block as Block>::Hash, ) -> Result<<Block as Block>::Header, Error>

Get block header. Returns UnknownBlock error if block is not found.

source

fn expect_block_number_from_id( &self, id: &BlockId<Block>, ) -> Result<<<Block as Block>::Header as Header>::Number, Error>

Convert an arbitrary block ID into a block number. Returns UnknownBlock error if block is not found.

source

fn expect_block_hash_from_id( &self, id: &BlockId<Block>, ) -> Result<<Block as Block>::Hash, Error>

Convert an arbitrary block ID into a block hash. Returns UnknownBlock error if block is not found.

Implementations on Foreign Types§

§

impl<B, E, Block, RA> HeaderBackend<Block> for &Client<B, E, Block, RA>
where B: Backend<Block>, E: CallExecutor<Block> + Send + Sync, Block: Block, RA: Send + Sync,

§

fn header( &self, hash: <Block as Block>::Hash, ) -> Result<Option<<Block as Block>::Header>, Error>

§

fn info(&self) -> Info<Block>

§

fn status(&self, hash: <Block as Block>::Hash) -> Result<BlockStatus, Error>

§

fn number( &self, hash: <Block as Block>::Hash, ) -> Result<Option<<<Block as Block>::Header as Header>::Number>, Error>

§

fn hash( &self, number: <<Block as Block>::Header as Header>::Number, ) -> Result<Option<<Block as Block>::Hash>, Error>

§

impl<B, E, Block, RA> HeaderBackend<Block> for Client<B, E, Block, RA>
where B: Backend<Block>, E: CallExecutor<Block> + Send + Sync, Block: Block, RA: Send + Sync,

§

fn header( &self, hash: <Block as Block>::Hash, ) -> Result<Option<<Block as Block>::Header>, Error>

§

fn info(&self) -> Info<Block>

§

fn status(&self, hash: <Block as Block>::Hash) -> Result<BlockStatus, Error>

§

fn number( &self, hash: <Block as Block>::Hash, ) -> Result<Option<<<Block as Block>::Header as Header>::Number>, Error>

§

fn hash( &self, number: <<Block as Block>::Header as Header>::Number, ) -> Result<Option<<Block as Block>::Hash>, Error>

source§

impl<Block> HeaderBackend<Block> for Blockchain<Block>
where Block: Block,

source§

fn header( &self, hash: <Block as Block>::Hash, ) -> Result<Option<<Block as Block>::Header>, Error>

source§

fn info(&self) -> Info<Block>

source§

fn status(&self, hash: <Block as Block>::Hash) -> Result<BlockStatus, Error>

source§

fn number( &self, hash: <Block as Block>::Hash, ) -> Result<Option<<<Block as Block>::Header as Header>::Number>, Error>

source§

fn hash( &self, number: <<Block as Block>::Header as Header>::Number, ) -> Result<Option<<Block as Block>::Hash>, Error>

source§

impl<Block> HeaderBackend<Block> for BlockchainDb<Block>
where Block: Block,

source§

fn header( &self, hash: <Block as Block>::Hash, ) -> Result<Option<<Block as Block>::Header>, Error>

source§

fn info(&self) -> Info<Block>

source§

fn status(&self, hash: <Block as Block>::Hash) -> Result<BlockStatus, Error>

source§

fn number( &self, hash: <Block as Block>::Hash, ) -> Result<Option<<<Block as Block>::Header as Header>::Number>, Error>

source§

fn hash( &self, number: <<Block as Block>::Header as Header>::Number, ) -> Result<Option<<Block as Block>::Hash>, Error>

source§

impl<Client, Block> HeaderBackend<Block> for DefaultSubsystemClient<Client>
where Client: HeaderBackend<Block>, Block: Block,

source§

fn header( &self, hash: <Block as Block>::Hash, ) -> Result<Option<<Block as Block>::Header>, Error>

source§

fn info(&self) -> Info<Block>

source§

fn status(&self, hash: <Block as Block>::Hash) -> Result<BlockStatus, Error>

source§

fn number( &self, hash: <Block as Block>::Hash, ) -> Result<Option<<<Block as Block>::Header as Header>::Number>, Error>

source§

fn hash( &self, number: <<Block as Block>::Header as Header>::Number, ) -> Result<Option<<Block as Block>::Hash>, Error>

Implementors§