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§
Sourcefn body(
&self,
hash: <Block as Block>::Hash,
) -> Result<Option<Vec<<Block as Block>::Extrinsic>>, Error>
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.
Sourcefn justifications(
&self,
hash: <Block as Block>::Hash,
) -> Result<Option<Justifications>, Error>
fn justifications( &self, hash: <Block as Block>::Hash, ) -> Result<Option<Justifications>, Error>
Get block justifications. Returns None if no justification exists.
Sourcefn last_finalized(&self) -> Result<<Block as Block>::Hash, Error>
fn last_finalized(&self) -> Result<<Block as Block>::Hash, Error>
Get last finalized block hash.
Sourcefn leaves(&self) -> Result<Vec<<Block as Block>::Hash>, Error>
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.
Sourcefn children(
&self,
parent_hash: <Block as Block>::Hash,
) -> Result<Vec<<Block as Block>::Hash>, Error>
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.
Sourcefn indexed_transaction(
&self,
hash: <Block as Block>::Hash,
) -> Result<Option<Vec<u8>>, Error>
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.
fn block_indexed_body( &self, hash: <Block as Block>::Hash, ) -> Result<Option<Vec<Vec<u8>>>, Error>
Provided Methods§
Sourcefn longest_containing(
&self,
base_hash: <Block as Block>::Hash,
import_lock: &RwLock<RawRwLock, ()>,
) -> Result<Option<<Block as Block>::Hash>, Error>
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.
Sourcefn has_indexed_transaction(
&self,
hash: <Block as Block>::Hash,
) -> Result<bool, Error>
fn has_indexed_transaction( &self, hash: <Block as Block>::Hash, ) -> Result<bool, Error>
Check if indexed transaction exists.
Sourcefn 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>
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.