Trait sp_blockchain::Backend
source · pub trait Backend<Block: BlockT>: HeaderBackend<Block> + HeaderMetadata<Block, Error = Error> {
// Required methods
fn body(
&self,
hash: Block::Hash,
) -> Result<Option<Vec<<Block as BlockT>::Extrinsic>>>;
fn justifications(
&self,
hash: Block::Hash,
) -> Result<Option<Justifications>>;
fn last_finalized(&self) -> Result<Block::Hash>;
fn leaves(&self) -> Result<Vec<Block::Hash>>;
fn children(&self, parent_hash: Block::Hash) -> Result<Vec<Block::Hash>>;
fn indexed_transaction(&self, hash: Block::Hash) -> Result<Option<Vec<u8>>>;
fn block_indexed_body(
&self,
hash: Block::Hash,
) -> Result<Option<Vec<Vec<u8>>>>;
// Provided methods
fn longest_containing(
&self,
base_hash: Block::Hash,
import_lock: &RwLock<()>,
) -> Result<Option<Block::Hash>> { ... }
fn has_indexed_transaction(&self, hash: Block::Hash) -> Result<bool> { ... }
fn displaced_leaves_after_finalizing(
&self,
finalized_block_hash: Block::Hash,
finalized_block_number: NumberFor<Block>,
) -> Result<DisplacedLeavesAfterFinalization<Block>, Error> { ... }
}
Expand description
Blockchain database backend. Does not perform any validation.
Required Methods§
sourcefn body(
&self,
hash: Block::Hash,
) -> Result<Option<Vec<<Block as BlockT>::Extrinsic>>>
fn body( &self, hash: Block::Hash, ) -> Result<Option<Vec<<Block as BlockT>::Extrinsic>>>
Get block body. Returns None
if block is not found.
sourcefn justifications(&self, hash: Block::Hash) -> Result<Option<Justifications>>
fn justifications(&self, hash: Block::Hash) -> Result<Option<Justifications>>
Get block justifications. Returns None
if no justification exists.
sourcefn last_finalized(&self) -> Result<Block::Hash>
fn last_finalized(&self) -> Result<Block::Hash>
Get last finalized block hash.
sourcefn leaves(&self) -> Result<Vec<Block::Hash>>
fn leaves(&self) -> Result<Vec<Block::Hash>>
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::Hash) -> Result<Vec<Block::Hash>>
fn children(&self, parent_hash: Block::Hash) -> Result<Vec<Block::Hash>>
Return hashes of all blocks that are children of the block with parent_hash
.
sourcefn indexed_transaction(&self, hash: Block::Hash) -> Result<Option<Vec<u8>>>
fn indexed_transaction(&self, hash: Block::Hash) -> Result<Option<Vec<u8>>>
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::Hash) -> Result<Option<Vec<Vec<u8>>>>
Provided Methods§
sourcefn longest_containing(
&self,
base_hash: Block::Hash,
import_lock: &RwLock<()>,
) -> Result<Option<Block::Hash>>
fn longest_containing( &self, base_hash: Block::Hash, import_lock: &RwLock<()>, ) -> Result<Option<Block::Hash>>
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::Hash) -> Result<bool>
fn has_indexed_transaction(&self, hash: Block::Hash) -> Result<bool>
Check if indexed transaction exists.
sourcefn displaced_leaves_after_finalizing(
&self,
finalized_block_hash: Block::Hash,
finalized_block_number: NumberFor<Block>,
) -> Result<DisplacedLeavesAfterFinalization<Block>, Error>
fn displaced_leaves_after_finalizing( &self, finalized_block_hash: Block::Hash, finalized_block_number: NumberFor<Block>, ) -> Result<DisplacedLeavesAfterFinalization<Block>, Error>
Returns all leaves that will be displaced after the block finalization.