Trait sp_blockchain::Backend[][src]

pub trait Backend<Block: BlockT>: HeaderBackend<Block> + HeaderMetadata<Block, Error = Error> {
    fn body(
        &self,
        id: BlockId<Block>
    ) -> Result<Option<Vec<<Block as BlockT>::Extrinsic>>>;
fn justifications(
        &self,
        id: BlockId<Block>
    ) -> Result<Option<Justifications>>;
fn last_finalized(&self) -> Result<Block::Hash>;
fn cache(&self) -> Option<Arc<dyn Cache<Block>>>;
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 best_containing(
        &self,
        target_hash: Block::Hash,
        maybe_max_number: Option<NumberFor<Block>>,
        import_lock: &RwLock<()>
    ) -> Result<Option<Block::Hash>> { ... }
fn has_indexed_transaction(&self, hash: &Block::Hash) -> Result<bool> { ... } }

Blockchain database backend. Does not perform any validation.

Required methods

fn body(
    &self,
    id: BlockId<Block>
) -> Result<Option<Vec<<Block as BlockT>::Extrinsic>>>
[src]

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

fn justifications(&self, id: BlockId<Block>) -> Result<Option<Justifications>>[src]

Get block justifications. Returns None if no justification exists.

fn last_finalized(&self) -> Result<Block::Hash>[src]

Get last finalized block hash.

fn cache(&self) -> Option<Arc<dyn Cache<Block>>>[src]

Returns data cache reference, if it is enabled on this backend.

fn leaves(&self) -> Result<Vec<Block::Hash>>[src]

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.

fn children(&self, parent_hash: Block::Hash) -> Result<Vec<Block::Hash>>[src]

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

fn indexed_transaction(&self, hash: &Block::Hash) -> Result<Option<Vec<u8>>>[src]

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

Loading content...

Provided methods

fn best_containing(
    &self,
    target_hash: Block::Hash,
    maybe_max_number: Option<NumberFor<Block>>,
    import_lock: &RwLock<()>
) -> Result<Option<Block::Hash>>
[src]

Get the most recent block hash of the best (longest) chains that contain block with the given target_hash.

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

If maybe_max_block_number is Some(max_block_number) the search is limited to block numbers <= max_block_number. in other words as if there were no blocks greater max_block_number. Returns Ok(None) if target_hash is not found in search space. TODO: document time complexity of this, see #1444

fn has_indexed_transaction(&self, hash: &Block::Hash) -> Result<bool>[src]

Check if indexed transaction exists.

Loading content...

Implementors

Loading content...