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§
Sourcetype Error: Debug + Display
type Error: Debug + Display
Errors that may occur within a HeaderStore.
Required Methods§
Sourcefn 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 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.
Sourcefn stage(&mut self, changes: BlockHeaderChanges)
fn stage(&mut self, changes: BlockHeaderChanges)
Stage changes to the chain to be written in the future.
Sourcefn write(
&mut self,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + '_>>
fn write( &mut self, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + '_>>
Commit the changes by writing them to disk.
Sourcefn height_of<'a>(
&'a mut self,
hash: &'a BlockHash,
) -> Pin<Box<dyn Future<Output = Result<Option<u32>, Self::Error>> + Send + 'a>>
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.
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.