@@ -3,7 +3,6 @@ use std::sync::Arc;
3
3
use std:: time:: Duration ;
4
4
5
5
use anyhow:: { anyhow, Context } ;
6
- use async_trait:: async_trait;
7
6
use tokio:: sync:: Mutex ;
8
7
9
8
use mithril_common:: api_version:: APIVersionProvider ;
@@ -50,30 +49,23 @@ use crate::{
50
49
/// The `DependenciesBuilder` is intended to manage Services instance creation.
51
50
///
52
51
/// The goal of this is to put all this code out of the way of business code.
53
- #[ async_trait]
54
- pub trait DependenciesBuilder {
55
- /// Create a SignerService instance.
56
- async fn build ( & self ) -> StdResult < SignerDependencyContainer > ;
57
- }
58
-
59
- /// A `DependenciesBuilder` for Production environment.
60
- pub struct ProductionDependenciesBuilder < ' a > {
52
+ pub struct DependenciesBuilder < ' a > {
61
53
config : & ' a Configuration ,
62
54
chain_observer_builder : fn ( & Configuration ) -> StdResult < Arc < dyn ChainObserver > > ,
63
55
immutable_file_observer_builder :
64
56
fn ( & Configuration ) -> StdResult < Arc < dyn ImmutableFileObserver > > ,
65
57
}
66
58
67
- impl < ' a > ProductionDependenciesBuilder < ' a > {
68
- /// Create a new `ProductionDependenciesBuilder `.
59
+ impl < ' a > DependenciesBuilder < ' a > {
60
+ /// Create a new `DependenciesBuilder `.
69
61
pub fn new ( config : & ' a Configuration ) -> Self {
70
62
let chain_observer_builder: fn ( & Configuration ) -> StdResult < Arc < dyn ChainObserver > > =
71
63
|config : & Configuration | {
72
64
let chain_observer_type = ChainObserverType :: Pallas ;
73
65
let cardano_cli_path = & config. cardano_cli_path ;
74
66
let cardano_node_socket_path = & config. cardano_node_socket_path ;
75
67
let cardano_network = & config. get_network ( ) . with_context ( || {
76
- "Production Dependencies Builder can not get Cardano network while building the chain observer"
68
+ "Dependencies Builder can not get Cardano network while building the chain observer"
77
69
} ) ?;
78
70
let cardano_cli_runner = & CardanoCliRunner :: new (
79
71
cardano_cli_path. to_owned ( ) ,
@@ -183,12 +175,9 @@ impl<'a> ProductionDependenciesBuilder<'a> {
183
175
184
176
Ok ( connection)
185
177
}
186
- }
187
178
188
- #[ async_trait]
189
- impl < ' a > DependenciesBuilder for ProductionDependenciesBuilder < ' a > {
190
179
/// Build dependencies for the Production environment.
191
- async fn build ( & self ) -> StdResult < SignerDependencyContainer > {
180
+ pub async fn build ( & self ) -> StdResult < SignerDependencyContainer > {
192
181
if !self . config . data_stores_directory . exists ( ) {
193
182
fs:: create_dir_all ( self . config . data_stores_directory . clone ( ) ) . with_context ( || {
194
183
format ! (
@@ -404,7 +393,7 @@ mod tests {
404
393
-> StdResult < Arc < dyn ImmutableFileObserver > > =
405
394
|_config : & Configuration | Ok ( Arc :: new ( DumbImmutableFileObserver :: default ( ) ) ) ;
406
395
407
- let mut dependencies_builder = ProductionDependenciesBuilder :: new ( & config) ;
396
+ let mut dependencies_builder = DependenciesBuilder :: new ( & config) ;
408
397
dependencies_builder
409
398
. override_chain_observer_builder ( chain_observer_builder)
410
399
. override_immutable_file_observer_builder ( immutable_file_observer_builder)
0 commit comments