Trait polkadot_service::HeaderBackend
source · pub trait HeaderBackend<Block>: Send + Syncwhere
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§
sourcefn header(
&self,
hash: <Block as Block>::Hash,
) -> Result<Option<<Block as Block>::Header>, Error>
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.
Provided Methods§
sourcefn block_hash_from_id(
&self,
id: &BlockId<Block>,
) -> Result<Option<<Block as Block>::Hash>, Error>
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.
sourcefn block_number_from_id(
&self,
id: &BlockId<Block>,
) -> Result<Option<<<Block as Block>::Header as Header>::Number>, Error>
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.
sourcefn expect_header(
&self,
hash: <Block as Block>::Hash,
) -> Result<<Block as Block>::Header, Error>
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.