Skip to main content

Backend

Trait Backend 

Source
pub trait Backend<Block>: HeaderBackend<Block> + HeaderMetadata<Block, Error = Error>
where Block: Block,
{ // Required methods fn body( &self, hash: <Block as Block>::Hash, ) -> Result<Option<Vec<<Block as Block>::Extrinsic>>, Error>; fn justifications( &self, hash: <Block as Block>::Hash, ) -> Result<Option<Justifications>, Error>; fn last_finalized(&self) -> Result<<Block as Block>::Hash, Error>; fn leaves(&self) -> Result<Vec<<Block as Block>::Hash>, Error>; fn children( &self, parent_hash: <Block as Block>::Hash, ) -> Result<Vec<<Block as Block>::Hash>, Error>; fn indexed_transaction( &self, hash: <Block as Block>::Hash, ) -> Result<Option<Vec<u8>>, Error>; fn block_indexed_body( &self, hash: <Block as Block>::Hash, ) -> Result<Option<Vec<Vec<u8>>>, Error>; // Provided methods fn longest_containing( &self, base_hash: <Block as Block>::Hash, import_lock: &RwLock<RawRwLock, ()>, ) -> Result<Option<<Block as Block>::Hash>, Error> { ... } fn has_indexed_transaction( &self, hash: <Block as Block>::Hash, ) -> Result<bool, Error> { ... } fn displaced_leaves_after_finalizing( &self, finalized_block_hash: <Block as Block>::Hash, finalized_block_number: <<Block as Block>::Header as Header>::Number, finalized_block_parent_hash: <Block as Block>::Hash, ) -> Result<DisplacedLeavesAfterFinalization<Block>, Error> { ... } }
Expand description

Blockchain database backend. Does not perform any validation.

Required Methods§

Source

fn body( &self, hash: <Block as Block>::Hash, ) -> Result<Option<Vec<<Block as Block>::Extrinsic>>, Error>

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

Source

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

Get block justifications. Returns None if no justification exists.

Source

fn last_finalized(&self) -> Result<<Block as Block>::Hash, Error>

Get last finalized block hash.

Source

fn leaves(&self) -> Result<Vec<<Block as Block>::Hash>, Error>

Returns hashes of all blocks that are leaves of the block tree. in other words, that have no children, are chain heads. Results must be ordered best (longest, highest) chain first.

Source

fn children( &self, parent_hash: <Block as Block>::Hash, ) -> Result<Vec<<Block as Block>::Hash>, Error>

Return hashes of all blocks that are children of the block with parent_hash.

Source

fn indexed_transaction( &self, hash: <Block as Block>::Hash, ) -> Result<Option<Vec<u8>>, Error>

Get single indexed transaction by content hash. Note that this will only fetch transactions that are indexed by the runtime with storage_index_transaction.

Source

fn block_indexed_body( &self, hash: <Block as Block>::Hash, ) -> Result<Option<Vec<Vec<u8>>>, Error>

Provided Methods§

Source

fn longest_containing( &self, base_hash: <Block as Block>::Hash, import_lock: &RwLock<RawRwLock, ()>, ) -> Result<Option<<Block as Block>::Hash>, Error>

Get the most recent block hash of the longest chain that contains a block with the given base_hash.

The search space is always limited to blocks which are in the finalized chain or descendants of it.

Returns Ok(None) if base_hash is not found in search space.

Source

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

Check if indexed transaction exists.

Source

fn displaced_leaves_after_finalizing( &self, finalized_block_hash: <Block as Block>::Hash, finalized_block_number: <<Block as Block>::Header as Header>::Number, finalized_block_parent_hash: <Block as Block>::Hash, ) -> Result<DisplacedLeavesAfterFinalization<Block>, Error>

Returns all leaves that will be displaced after the block finalization.

Implementors§

Source§

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

Source§

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