mithril_common/signable_builder/
interface.rsuse async_trait::async_trait;
use std::fmt::Debug;
use crate::{
entities::{
BlockNumber, CardanoDatabaseSnapshot, CardanoDbBeacon, CardanoStakeDistribution,
CardanoTransactionsSnapshot, Epoch, MithrilStakeDistribution, ProtocolMessage,
ProtocolMessagePartValue, Snapshot,
},
StdResult,
};
#[cfg(test)]
use mockall::automock;
pub trait Beacon: Send + Sync {}
#[cfg_attr(not(target_family = "wasm"), typetag::serde(tag = "type"))]
pub trait Artifact: Debug + Send + Sync {
fn get_id(&self) -> String;
}
#[cfg_attr(test, automock)]
#[async_trait]
pub trait SignableBuilder<U>: Send + Sync
where
U: Beacon,
{
async fn compute_protocol_message(&self, beacon: U) -> StdResult<ProtocolMessage>;
}
#[cfg_attr(test, automock)]
#[async_trait]
pub trait SignableSeedBuilder: Send + Sync {
async fn compute_next_aggregate_verification_key(&self) -> StdResult<ProtocolMessagePartValue>;
async fn compute_next_protocol_parameters(&self) -> StdResult<ProtocolMessagePartValue>;
async fn compute_current_epoch(&self) -> StdResult<ProtocolMessagePartValue>;
}
impl Beacon for BlockNumber {}
impl Beacon for CardanoDbBeacon {}
impl Beacon for Epoch {}
#[cfg_attr(not(target_family = "wasm"), typetag::serde)]
impl Artifact for CardanoDatabaseSnapshot {
fn get_id(&self) -> String {
self.hash.clone()
}
}
#[cfg_attr(not(target_family = "wasm"), typetag::serde)]
impl Artifact for CardanoStakeDistribution {
fn get_id(&self) -> String {
self.hash.clone()
}
}
#[cfg_attr(not(target_family = "wasm"), typetag::serde)]
impl Artifact for CardanoTransactionsSnapshot {
fn get_id(&self) -> String {
self.hash.clone()
}
}
#[cfg_attr(not(target_family = "wasm"), typetag::serde)]
impl Artifact for MithrilStakeDistribution {
fn get_id(&self) -> String {
self.hash.clone()
}
}
#[cfg_attr(not(target_family = "wasm"), typetag::serde)]
impl Artifact for Snapshot {
fn get_id(&self) -> String {
self.digest.clone()
}
}