HeaderStore

Trait HeaderStore 

Source
pub trait HeaderStore:
    Debug
    + Send
    + Sync {
    type Error: Debug + Display;

    // Required methods
    fn load<'a>(
        &'a mut self,
        range: impl RangeBounds<u32> + Send + Sync + 'a,
    ) -> Pin<Box<dyn Future<Output = Result<BTreeMap<u32, Header>, Self::Error>> + Send + 'a>>;
    fn stage(&mut self, changes: BlockHeaderChanges);
    fn write(
        &mut self,
    ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + '_>>;
    fn height_of<'a>(
        &'a mut self,
        hash: &'a BlockHash,
    ) -> Pin<Box<dyn Future<Output = Result<Option<u32>, Self::Error>> + Send + 'a>>;
    fn hash_at(
        &mut self,
        height: u32,
    ) -> Pin<Box<dyn Future<Output = Result<Option<BlockHash>, Self::Error>> + Send + '_>>;
    fn header_at(
        &mut self,
        height: u32,
    ) -> Pin<Box<dyn Future<Output = Result<Option<Header>, Self::Error>> + Send + '_>>;
}
Expand description

Methods required to persist the chain of block headers.

Required Associated Types§

Source

type Error: Debug + Display

Errors that may occur within a HeaderStore.

Required Methods§

Source

fn load<'a>( &'a mut self, range: impl RangeBounds<u32> + Send + Sync + 'a, ) -> Pin<Box<dyn Future<Output = Result<BTreeMap<u32, Header>, Self::Error>> + Send + 'a>>

Load the headers of the canonical chain for the specified range.

Source

fn stage(&mut self, changes: BlockHeaderChanges)

Stage changes to the chain to be written in the future.

Source

fn write( &mut self, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + '_>>

Commit the changes by writing them to disk.

Source

fn height_of<'a>( &'a mut self, hash: &'a BlockHash, ) -> Pin<Box<dyn Future<Output = Result<Option<u32>, Self::Error>> + Send + 'a>>

Return the height of a block hash in the database, if it exists.

Source

fn hash_at( &mut self, height: u32, ) -> Pin<Box<dyn Future<Output = Result<Option<BlockHash>, Self::Error>> + Send + '_>>

Return the hash at the height in the database, if it exists.

Source

fn header_at( &mut self, height: u32, ) -> Pin<Box<dyn Future<Output = Result<Option<Header>, Self::Error>> + Send + '_>>

Return the header at the height in the database, if it exists.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§