mithril_cardano_node_chain/chain_observer/
interface.rs1use async_trait::async_trait;
2use thiserror::Error;
3
4use mithril_common::StdError;
5use mithril_common::crypto_helper::KesPeriod;
6use mithril_common::entities::{ChainPoint, Epoch, StakeDistribution};
7
8use crate::entities::{ChainAddress, TxDatum};
9
10#[derive(Debug, Error)]
12pub enum ChainObserverError {
13 #[error("general error")]
15 General(#[source] StdError),
16
17 #[error("could not parse content")]
19 InvalidContent(#[source] StdError),
20}
21
22#[cfg_attr(test, mockall::automock)]
24#[async_trait]
25pub trait ChainObserver: Sync + Send {
26 async fn get_current_datums(
28 &self,
29 address: &ChainAddress,
30 ) -> Result<Vec<TxDatum>, ChainObserverError>;
31
32 async fn get_current_era(&self) -> Result<Option<String>, ChainObserverError>;
34
35 async fn get_current_epoch(&self) -> Result<Option<Epoch>, ChainObserverError>;
37
38 async fn get_current_chain_point(&self) -> Result<Option<ChainPoint>, ChainObserverError>;
40
41 async fn get_current_stake_distribution(
43 &self,
44 ) -> Result<Option<StakeDistribution>, ChainObserverError>;
45
46 async fn get_current_kes_period(&self) -> Result<Option<KesPeriod>, ChainObserverError> {
48 Ok(None)
49 }
50}