mithril_signer/dependency_injection/
containers.rs

1use std::sync::Arc;
2
3use mithril_common::api_version::APIVersionProvider;
4use mithril_common::chain_observer::ChainObserver;
5use mithril_common::digesters::ImmutableDigester;
6use mithril_common::era::{EraChecker, EraReader};
7use mithril_common::signable_builder::SignableBuilderService;
8use mithril_common::TickerService;
9use mithril_signed_entity_lock::SignedEntityTypeLock;
10use mithril_signed_entity_preloader::CardanoTransactionsPreloader;
11
12use mithril_persistence::store::StakeStorer;
13use tokio::sync::RwLock;
14
15use crate::services::{
16    AggregatorClient, CertifierService, EpochService, SingleSigner, UpkeepService,
17};
18use crate::store::ProtocolInitializerStorer;
19use crate::MetricsService;
20
21type StakeStoreService = Arc<dyn StakeStorer>;
22type CertificateHandlerService = Arc<dyn AggregatorClient>;
23type ChainObserverService = Arc<dyn ChainObserver>;
24type DigesterService = Arc<dyn ImmutableDigester>;
25type SingleSignerService = Arc<dyn SingleSigner>;
26type TimePointProviderService = Arc<dyn TickerService>;
27type ProtocolInitializerStoreService = Arc<dyn ProtocolInitializerStorer>;
28
29/// EpochServiceWrapper wraps a [EpochService]
30pub type EpochServiceWrapper = Arc<RwLock<dyn EpochService>>;
31
32/// This structure groups all the dependencies required by the state machine.
33pub struct SignerDependencyContainer {
34    /// Time point provider service
35    pub ticker_service: TimePointProviderService,
36
37    /// Stake store service
38    pub stake_store: StakeStoreService,
39
40    /// Certificate handler service
41    pub certificate_handler: CertificateHandlerService,
42
43    /// Chain Observer service
44    pub chain_observer: ChainObserverService,
45
46    /// Digester service
47    pub digester: DigesterService,
48
49    /// SingleSigner service
50    pub single_signer: SingleSignerService,
51
52    /// ProtocolInitializer store
53    pub protocol_initializer_store: ProtocolInitializerStoreService,
54
55    /// Era checker service
56    pub era_checker: Arc<EraChecker>,
57
58    /// Era reader service
59    pub era_reader: Arc<EraReader>,
60
61    /// API version provider
62    pub api_version_provider: Arc<APIVersionProvider>,
63
64    /// Signable Builder Service
65    pub signable_builder_service: Arc<dyn SignableBuilderService>,
66
67    /// Metrics service
68    pub metrics_service: Arc<MetricsService>,
69
70    /// Signed entity type lock
71    pub signed_entity_type_lock: Arc<SignedEntityTypeLock>,
72
73    /// Cardano transactions preloader
74    pub cardano_transactions_preloader: Arc<CardanoTransactionsPreloader>,
75
76    /// Upkeep service
77    pub upkeep_service: Arc<dyn UpkeepService>,
78
79    /// Epoch service
80    pub epoch_service: EpochServiceWrapper,
81
82    /// Certifier service
83    pub certifier: Arc<dyn CertifierService>,
84}