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, Version, Version)>>>;
fn insert_stake_table(
&self,
epoch: EpochNumber,
stake_table: &StakeTableState,
epoch_root_protocol_version: Version,
next_epoch_root_protocol_version: Version,
) -> impl Send + Future<Output = Result<()>>;
}Expand description
Client-side database for a [LightClient].
Required Methods§
Sourcefn default() -> impl Send + Future<Output = Result<Self>>
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())).
Sourcefn block_height(&self) -> impl Send + Future<Output = Result<u64>>
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.
Sourcefn leaf_upper_bound(
&self,
leaf: impl Into<LeafRequest> + Send,
) -> impl Send + Future<Output = Result<Option<LeafQueryData<SeqTypes>>>>
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.
Sourcefn get_leaves_in_range(
&self,
start: u32,
end: u32,
) -> impl Send + Future<Output = Result<Vec<LeafQueryData<SeqTypes>>>>
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)
Sourcefn insert_leaf(
&self,
leaf: LeafQueryData<SeqTypes>,
) -> impl Send + Future<Output = Result<()>>
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.
Sourcefn stake_table_lower_bound(
&self,
epoch: EpochNumber,
) -> impl Send + Future<Output = Result<Option<(EpochNumber, StakeTableState, Version, Version)>>>
fn stake_table_lower_bound( &self, epoch: EpochNumber, ) -> impl Send + Future<Output = Result<Option<(EpochNumber, StakeTableState, Version, Version)>>>
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 loaded epoch number, the stake table state, the protocol version of the epoch root header under whose rules that stake table’s active set was selected, and the protocol version of the epoch root header in the next epoch (used to seed iter 1 of a catchup that resumes from this row).
Sourcefn insert_stake_table(
&self,
epoch: EpochNumber,
stake_table: &StakeTableState,
epoch_root_protocol_version: Version,
next_epoch_root_protocol_version: Version,
) -> impl Send + Future<Output = Result<()>>
fn insert_stake_table( &self, epoch: EpochNumber, stake_table: &StakeTableState, epoch_root_protocol_version: Version, next_epoch_root_protocol_version: Version, ) -> impl Send + Future<Output = Result<()>>
Add a stake table to the cache.
epoch_root_protocol_version is the protocol version of the epoch root header in epoch
e-2 (the snapshot point), used so that future cache hits can apply the same active-set
selection rules without re-fetching the root.
next_epoch_root_protocol_version is the protocol version of the epoch root header in
epoch e-1 (the snapshot point for e+1), used so that a future catchup resuming from
this row can seed iter 1’s filter version without re-fetching that root.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
Source§impl<T: Storage> Storage for Arc<T>
impl<T: Storage> Storage for Arc<T>
async fn default() -> Result<Self>
async fn block_height(&self) -> Result<u64>
async fn leaf_upper_bound( &self, leaf: impl Into<LeafRequest> + Send, ) -> Result<Option<LeafQueryData<SeqTypes>>>
async fn get_leaves_in_range( &self, start: u32, end: u32, ) -> Result<Vec<LeafQueryData<SeqTypes>>>
async fn insert_leaf(&self, leaf: LeafQueryData<SeqTypes>) -> Result<()>
async fn stake_table_lower_bound( &self, epoch: EpochNumber, ) -> Result<Option<(EpochNumber, StakeTableState, Version, Version)>>
async fn insert_stake_table( &self, epoch: EpochNumber, stake_table: &StakeTableState, epoch_root_protocol_version: Version, next_epoch_root_protocol_version: Version, ) -> Result<()>
Implementors§
impl Storage for SqlStorage
client only.