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§
Sourcefn genesis(&self) -> <Self::Block as Block>::Identifier
fn genesis(&self) -> <Self::Block as Block>::Identifier
Get the genesis hash of the chain.
Sourcefn head(&self) -> <Self::Block as Block>::Identifier
fn head(&self) -> <Self::Block as Block>::Identifier
Get the head of the chain.
Sourcefn contains(
&self,
hash: &<Self::Block as Block>::Identifier,
) -> Result<bool, Self::Error>
fn contains( &self, hash: &<Self::Block as Block>::Identifier, ) -> Result<bool, Self::Error>
Check whether a hash is contained in the chain.
Sourcefn is_canon(
&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>
Check whether a block is canonical.
Sourcefn lookup_canon_depth(
&self,
depth: usize,
) -> Result<Option<<Self::Block as Block>::Identifier>, Self::Error>
fn lookup_canon_depth( &self, depth: usize, ) -> Result<Option<<Self::Block as Block>::Identifier>, Self::Error>
Look up a canonical block via its depth.
Sourcefn auxiliary(
&self,
key: &<Self::Auxiliary as Auxiliary<Self::Block>>::Key,
) -> Result<Option<Self::Auxiliary>, Self::Error>
fn auxiliary( &self, key: &<Self::Auxiliary as Auxiliary<Self::Block>>::Key, ) -> Result<Option<Self::Auxiliary>, Self::Error>
Get the auxiliary value by key.
Sourcefn depth_at(
&self,
hash: &<Self::Block as Block>::Identifier,
) -> Result<usize, Self::Error>
fn depth_at( &self, hash: &<Self::Block as Block>::Identifier, ) -> Result<usize, Self::Error>
Get the depth of a block.
Sourcefn children_at(
&self,
hash: &<Self::Block as Block>::Identifier,
) -> Result<Vec<<Self::Block as Block>::Identifier>, Self::Error>
fn children_at( &self, hash: &<Self::Block as Block>::Identifier, ) -> Result<Vec<<Self::Block as Block>::Identifier>, Self::Error>
Get children of a block.