Storage

Trait Storage 

Source
pub trait Storage:
    Sized
    + Send
    + Sync
    + 'static {
    // Required methods
    fn default() -> impl Send + Future<Output = Result<Self>>;
    fn block_height(&self) -> impl Send + Future<Output = Result<u64>>;
    fn leaf_upper_bound(
        &self,
        leaf: impl Into<LeafRequest> + Send,
    ) -> impl Send + Future<Output = Result<Option<LeafQueryData<SeqTypes>>>>;
    fn get_leaves_in_range(
        &self,
        start: u32,
        end: u32,
    ) -> impl Send + Future<Output = Result<Vec<LeafQueryData<SeqTypes>>>>;
    fn insert_leaf(
        &self,
        leaf: LeafQueryData<SeqTypes>,
    ) -> impl Send + Future<Output = Result<()>>;
    fn stake_table_lower_bound(
        &self,
        epoch: EpochNumber,
    ) -> impl Send + Future<Output = Result<Option<(EpochNumber, StakeTableState)>>>;
    fn insert_stake_table(
        &self,
        epoch: EpochNumber,
        stake_table: &StakeTableState,
    ) -> impl Send + Future<Output = Result<()>>;
}
Expand description

Client-side database for a [LightClient].

Required Methods§

Source

fn default() -> impl Send + Future<Output = Result<Self>>

Create a default, empty instance of the state.

This is an async, fallible version of Default::default. If Self: Default, this is equivalent to ready(Ok(<Self as Default>::default())).

Source

fn block_height(&self) -> impl Send + Future<Output = Result<u64>>

Get the number of blocks known to be in the chain.

This is equivalent to one more than the block number of the latest known block.

Because the database is not constantly being updated, this may be an underestimate of the true number of blocks that exist.

Source

fn leaf_upper_bound( &self, leaf: impl Into<LeafRequest> + Send, ) -> impl Send + Future<Output = Result<Option<LeafQueryData<SeqTypes>>>>

Get the earliest available leaf which is later than or equal to the requested leaf.

This will either be the leaf requested, or can be used as the known-finalized endpoint in a leaf chain proving that requested leaf is finalized (after the requested leaf is fetched from elsewhere).

If there is no known leaf later than the requested leaf, the result is None.

Source

fn get_leaves_in_range( &self, start: u32, end: u32, ) -> impl Send + Future<Output = Result<Vec<LeafQueryData<SeqTypes>>>>

Get all leaves in the range [start, end)

Source

fn insert_leaf( &self, leaf: LeafQueryData<SeqTypes>, ) -> impl Send + Future<Output = Result<()>>

Add a leaf to the cache.

This may result in an older leaf being removed.

Source

fn stake_table_lower_bound( &self, epoch: EpochNumber, ) -> impl Send + Future<Output = Result<Option<(EpochNumber, StakeTableState)>>>

Get the stake table for the latest epoch which is not later than epoch.

If such a stake table is available in the database, returns the ordered entries and the epoch number of the stake table that was loaded.

Source

fn insert_stake_table( &self, epoch: EpochNumber, stake_table: &StakeTableState, ) -> impl Send + Future<Output = Result<()>>

Add a stake table to the cache.

This may result in an older stake table being removed.

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§