Trait ChainQuery

Source
pub trait ChainQuery: Store {
    // Required methods
    fn genesis(&self) -> <Self::Block as Block>::Identifier;
    fn head(&self) -> <Self::Block as Block>::Identifier;
    fn contains(
        &self,
        hash: &<Self::Block as Block>::Identifier,
    ) -> Result<bool, Self::Error>;
    fn is_canon(
        &self,
        hash: &<Self::Block as Block>::Identifier,
    ) -> Result<bool, Self::Error>;
    fn lookup_canon_depth(
        &self,
        depth: usize,
    ) -> Result<Option<<Self::Block as Block>::Identifier>, Self::Error>;
    fn auxiliary(
        &self,
        key: &<Self::Auxiliary as Auxiliary<Self::Block>>::Key,
    ) -> Result<Option<Self::Auxiliary>, Self::Error>;
    fn depth_at(
        &self,
        hash: &<Self::Block as Block>::Identifier,
    ) -> Result<usize, Self::Error>;
    fn children_at(
        &self,
        hash: &<Self::Block as Block>::Identifier,
    ) -> Result<Vec<<Self::Block as Block>::Identifier>, Self::Error>;
    fn state_at(
        &self,
        hash: &<Self::Block as Block>::Identifier,
    ) -> Result<Self::State, Self::Error>;
    fn block_at(
        &self,
        hash: &<Self::Block as Block>::Identifier,
    ) -> Result<Self::Block, Self::Error>;
}
Expand description

Chain query interface for a backend.

Required Methods§

Source

fn genesis(&self) -> <Self::Block as Block>::Identifier

Get the genesis hash of the chain.

Source

fn head(&self) -> <Self::Block as Block>::Identifier

Get the head of the chain.

Source

fn contains( &self, hash: &<Self::Block as Block>::Identifier, ) -> Result<bool, Self::Error>

Check whether a hash is contained in the chain.

Source

fn is_canon( &self, hash: &<Self::Block as Block>::Identifier, ) -> Result<bool, Self::Error>

Check whether a block is canonical.

Source

fn lookup_canon_depth( &self, depth: usize, ) -> Result<Option<<Self::Block as Block>::Identifier>, Self::Error>

Look up a canonical block via its depth.

Source

fn auxiliary( &self, key: &<Self::Auxiliary as Auxiliary<Self::Block>>::Key, ) -> Result<Option<Self::Auxiliary>, Self::Error>

Get the auxiliary value by key.

Source

fn depth_at( &self, hash: &<Self::Block as Block>::Identifier, ) -> Result<usize, Self::Error>

Get the depth of a block.

Source

fn children_at( &self, hash: &<Self::Block as Block>::Identifier, ) -> Result<Vec<<Self::Block as Block>::Identifier>, Self::Error>

Get children of a block.

Source

fn state_at( &self, hash: &<Self::Block as Block>::Identifier, ) -> Result<Self::State, Self::Error>

Get the state object of a block.

Source

fn block_at( &self, hash: &<Self::Block as Block>::Identifier, ) -> Result<Self::Block, Self::Error>

Get the object of a block.

Implementors§

Source§

impl<B: Block, A: Auxiliary<B>, S: Clone> ChainQuery for MemoryBackend<B, A, S>

Source§

impl<B: Block, A: Auxiliary<B>, S: Clone> ChainQuery for MemoryDatabase<B, A, S>

Source§

impl<B: Block, A: Auxiliary<B>, S: Clone> ChainQuery for SharedMemoryBackend<B, A, S>