Skip to content

Commit c1a1411

Browse files
committed
add pallaschainobserver in the dep injection passing the fallback
- added `pallaschainobserver` to `chain_observer` namespace - added `pallaschainobserver::new_with_fallback` to create the observer with a fallback - added a match for the `executionenvironment` in the `build_chain_observer` method to use the `pallaschainobserver` if in production mode.
1 parent abf1676 commit c1a1411

File tree

1 file changed

+14
-4
lines changed
  • mithril-aggregator/src/dependency_injection

1 file changed

+14
-4
lines changed

mithril-aggregator/src/dependency_injection/builder.rs

+14-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ use anyhow::Context;
44
use mithril_common::{
55
api_version::APIVersionProvider,
66
certificate_chain::{CertificateVerifier, MithrilCertificateVerifier},
7-
chain_observer::{CardanoCliChainObserver, CardanoCliRunner, ChainObserver, FakeObserver},
7+
chain_observer::{
8+
CardanoCliChainObserver, CardanoCliRunner, ChainObserver, FakeObserver, PallasChainObserver,
9+
},
810
crypto_helper::{
911
ProtocolGenesisSigner, ProtocolGenesisVerificationKey, ProtocolGenesisVerifier,
1012
},
@@ -463,9 +465,17 @@ impl DependenciesBuilder {
463465

464466
async fn build_chain_observer(&mut self) -> Result<Arc<dyn ChainObserver>> {
465467
let chain_observer: Arc<dyn ChainObserver> = match self.configuration.environment {
466-
ExecutionEnvironment::Production => Arc::new(CardanoCliChainObserver::new(
467-
self.get_cardano_cli_runner().await?,
468-
)),
468+
ExecutionEnvironment::Production => {
469+
let fallback = CardanoCliChainObserver::new(self.get_cardano_cli_runner().await?);
470+
let observer = PallasChainObserver::new_with_fallback(
471+
&self.configuration.cardano_node_socket_path,
472+
self.configuration.get_network().with_context(|| {
473+
"Dependencies Builder can not get Cardano network while building cardano cli runner"
474+
})?,
475+
fallback,
476+
);
477+
Arc::new(observer)
478+
}
469479
_ => Arc::new(FakeObserver::default()),
470480
};
471481

0 commit comments

Comments
 (0)