mithril_signer/store/
protocol_initializer_store.rs

1use async_trait::async_trait;
2
3use mithril_common::{crypto_helper::ProtocolInitializer, entities::Epoch, StdResult};
4
5#[cfg_attr(test, mockall::automock)]
6#[async_trait]
7/// Store the ProtocolInitializer used for each Epoch. This is useful because
8/// protocol parameters and stake distribution change over time.
9pub trait ProtocolInitializerStorer: Sync + Send {
10    /// Save a protocol initializer for the given Epoch.
11    async fn save_protocol_initializer(
12        &self,
13        epoch: Epoch,
14        protocol_initializer: ProtocolInitializer,
15    ) -> StdResult<Option<ProtocolInitializer>>;
16
17    /// Fetch a protocol initializer if any saved for the given Epoch.
18    async fn get_protocol_initializer(
19        &self,
20        epoch: Epoch,
21    ) -> StdResult<Option<ProtocolInitializer>>;
22
23    /// Return the list of the N last saved protocol initializers if any.
24    async fn get_last_protocol_initializer(
25        &self,
26        last: usize,
27    ) -> StdResult<Vec<(Epoch, ProtocolInitializer)>>;
28}