Trait sp_blockchain::HeaderBackend
source · pub trait HeaderBackend<Block: BlockT>: Send + Sync {
// Required methods
fn header(&self, hash: Block::Hash) -> Result<Option<Block::Header>>;
fn info(&self) -> Info<Block>;
fn status(&self, hash: Block::Hash) -> Result<BlockStatus>;
fn number(
&self,
hash: Block::Hash
) -> Result<Option<<<Block as BlockT>::Header as HeaderT>::Number>>;
fn hash(&self, number: NumberFor<Block>) -> Result<Option<Block::Hash>>;
// Provided methods
fn block_hash_from_id(
&self,
id: &BlockId<Block>
) -> Result<Option<Block::Hash>> { ... }
fn block_number_from_id(
&self,
id: &BlockId<Block>
) -> Result<Option<NumberFor<Block>>> { ... }
fn expect_header(&self, hash: Block::Hash) -> Result<Block::Header> { ... }
fn expect_block_number_from_id(
&self,
id: &BlockId<Block>
) -> Result<NumberFor<Block>> { ... }
fn expect_block_hash_from_id(
&self,
id: &BlockId<Block>
) -> Result<Block::Hash> { ... }
}
Expand description
Blockchain database header backend. Does not perform any validation.
Required Methods§
sourcefn header(&self, hash: Block::Hash) -> Result<Option<Block::Header>>
fn header(&self, hash: Block::Hash) -> Result<Option<Block::Header>>
Get block header. Returns None
if block is not found.
sourcefn status(&self, hash: Block::Hash) -> Result<BlockStatus>
fn status(&self, hash: Block::Hash) -> Result<BlockStatus>
Get block status.
Provided Methods§
sourcefn block_hash_from_id(&self, id: &BlockId<Block>) -> Result<Option<Block::Hash>>
fn block_hash_from_id(&self, id: &BlockId<Block>) -> Result<Option<Block::Hash>>
Convert an arbitrary block ID into a block hash.
sourcefn block_number_from_id(
&self,
id: &BlockId<Block>
) -> Result<Option<NumberFor<Block>>>
fn block_number_from_id( &self, id: &BlockId<Block> ) -> Result<Option<NumberFor<Block>>>
Convert an arbitrary block ID into a block hash.
sourcefn expect_header(&self, hash: Block::Hash) -> Result<Block::Header>
fn expect_header(&self, hash: Block::Hash) -> Result<Block::Header>
Get block header. Returns UnknownBlock
error if block is not found.
sourcefn expect_block_number_from_id(
&self,
id: &BlockId<Block>
) -> Result<NumberFor<Block>>
fn expect_block_number_from_id( &self, id: &BlockId<Block> ) -> Result<NumberFor<Block>>
Convert an arbitrary block ID into a block number. Returns UnknownBlock
error if block is
not found.
sourcefn expect_block_hash_from_id(&self, id: &BlockId<Block>) -> Result<Block::Hash>
fn expect_block_hash_from_id(&self, id: &BlockId<Block>) -> Result<Block::Hash>
Convert an arbitrary block ID into a block hash. Returns UnknownBlock
error if block is
not found.