1+ use mithril_protocol_config:: http_client:: http_impl:: HttpMithrilNetworkConfigurationProvider ;
12use std:: sync:: Arc ;
23use tokio:: sync:: RwLock ;
34
5+ use mithril_protocol_config:: interface:: MithrilNetworkConfigurationProvider ;
6+
47use crate :: dependency_injection:: { DependenciesBuilder , EpochServiceWrapper , Result } ;
58use crate :: get_dependency;
6- use crate :: services:: { EpochServiceDependencies , MithrilEpochService } ;
9+ use crate :: services:: {
10+ EpochServiceDependencies , LocalMithrilNetworkConfigurationProvider , MithrilEpochService ,
11+ } ;
12+
713impl DependenciesBuilder {
814 async fn build_epoch_service ( & mut self ) -> Result < EpochServiceWrapper > {
915 let verification_key_store = self . get_verification_key_store ( ) . await ?;
1016 let epoch_settings_storer = self . get_epoch_settings_store ( ) . await ?;
1117 let chain_observer = self . get_chain_observer ( ) . await ?;
1218 let era_checker = self . get_era_checker ( ) . await ?;
1319 let stake_store = self . get_stake_store ( ) . await ?;
14- //remove conf usage for epoch_settings and allowed_discriminants and send mithril_network_configuration instread
15- let epoch_settings = self . configuration . get_epoch_settings_configuration ( ) ;
1620 let allowed_discriminants = self
1721 . configuration
1822 . compute_allowed_signed_entity_types_discriminants ( ) ?;
1923
20- let network_configuration_provider = self . get_mithril_network_configuration_provider ( ) ;
2124 let epoch_service = Arc :: new ( RwLock :: new ( MithrilEpochService :: new (
22- network_configuration_provider ,
25+ self . get_mithril_network_configuration_provider ( ) . await ? ,
2326 EpochServiceDependencies :: new (
2427 epoch_settings_storer,
2528 verification_key_store,
@@ -38,4 +41,45 @@ impl DependenciesBuilder {
3841 pub async fn get_epoch_service ( & mut self ) -> Result < EpochServiceWrapper > {
3942 get_dependency ! ( self . epoch_service)
4043 }
44+
45+ async fn build_mithril_network_configuration_provider (
46+ & mut self ,
47+ ) -> Result < Arc < dyn MithrilNetworkConfigurationProvider > > {
48+ let network_configuration_provider: Arc < dyn MithrilNetworkConfigurationProvider > =
49+ if self . configuration . is_follower_aggregator ( ) {
50+ Arc :: new ( HttpMithrilNetworkConfigurationProvider :: new (
51+ self . get_leader_aggregator_client ( ) . await ?,
52+ ) )
53+ } else {
54+ Arc :: new ( LocalMithrilNetworkConfigurationProvider :: new (
55+ self . configuration . get_epoch_settings_configuration ( ) ,
56+ self . configuration
57+ . compute_allowed_signed_entity_types_discriminants ( ) ?,
58+ self . get_epoch_settings_store ( ) . await ?,
59+ ) )
60+ } ;
61+
62+ Ok ( network_configuration_provider)
63+ }
64+
65+ /// [MithrilNetworkConfigurationProvider][mithril_protocol_config::interface::MithrilNetworkConfigurationProvider] service
66+ pub async fn get_mithril_network_configuration_provider (
67+ & mut self ,
68+ ) -> Result < Arc < dyn MithrilNetworkConfigurationProvider > > {
69+ get_dependency ! ( self . mithril_network_configuration_provider)
70+ }
71+ }
72+
73+ // Todo remove after rebase with shared aggregator client:
74+ #[ async_trait:: async_trait]
75+ impl mithril_protocol_config:: http_client:: http_impl:: ProtocolConfigurationRetrieverFromAggregator
76+ for crate :: services:: AggregatorHTTPClient
77+ {
78+ /// Retrieves protocol configuration for a given epoch from the aggregator
79+ async fn retrieve_protocol_configuration (
80+ & self ,
81+ _epoch : mithril_common:: entities:: Epoch ,
82+ ) -> mithril_common:: StdResult < mithril_common:: messages:: ProtocolConfigurationMessage > {
83+ unimplemented ! ( )
84+ }
4185}
0 commit comments