Skip to content

Commit c7d529c

Browse files
committed
feat(aggregator): wire 'SignatureConsumerDmq' in DI
1 parent 55827c1 commit c7d529c

File tree

2 files changed

+33
-8
lines changed

2 files changed

+33
-8
lines changed

mithril-aggregator/src/configuration.rs

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,16 @@ pub trait ConfigurationSource {
6161
panic!("cardano_cli_path is not implemented.");
6262
}
6363

64-
/// Path of the socket used by the Cardano CLI tool
65-
/// to communicate with the Cardano node
64+
/// Path of the socket opened by the Cardano node
6665
fn cardano_node_socket_path(&self) -> PathBuf {
6766
panic!("cardano_node_socket_path is not implemented.");
6867
}
6968

69+
/// Path of the socket opened by the DMQ node
70+
fn dmq_node_socket_path(&self) -> Option<PathBuf> {
71+
panic!("dmq_node_socket_path is not implemented.");
72+
}
73+
7074
/// Cardano node version.
7175
///
7276
/// **NOTE**: This cannot be verified for now (see [this
@@ -390,11 +394,14 @@ pub struct ServeCommandConfiguration {
390394
#[example = "`cardano-cli`"]
391395
pub cardano_cli_path: PathBuf,
392396

393-
/// Path of the socket used by the Cardano CLI tool
394-
/// to communicate with the Cardano node
395-
#[example = "`/tmp/cardano.sock`"]
397+
/// Path of the socket opened by the Cardano node
398+
#[example = "`/ipc/node.socket`"]
396399
pub cardano_node_socket_path: PathBuf,
397400

401+
/// Path of the socket opened by the DMQ node
402+
#[example = "`/ipc/dmq.socket`"]
403+
pub dmq_node_socket_path: Option<PathBuf>,
404+
398405
/// Cardano node version.
399406
///
400407
/// **NOTE**: This cannot be verified for now (see [this
@@ -628,6 +635,7 @@ impl ServeCommandConfiguration {
628635
environment: ExecutionEnvironment::Test,
629636
cardano_cli_path: PathBuf::new(),
630637
cardano_node_socket_path: PathBuf::new(),
638+
dmq_node_socket_path: None,
631639
cardano_node_version: "0.0.1".to_string(),
632640
network_magic: Some(42),
633641
network: "devnet".to_string(),
@@ -707,6 +715,10 @@ impl ConfigurationSource for ServeCommandConfiguration {
707715
self.cardano_node_socket_path.clone()
708716
}
709717

718+
fn dmq_node_socket_path(&self) -> Option<PathBuf> {
719+
self.dmq_node_socket_path.clone()
720+
}
721+
710722
fn cardano_node_version(&self) -> String {
711723
self.cardano_node_version.clone()
712724
}

mithril-aggregator/src/dependency_injection/builder/enablers/misc.rs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,17 @@
77
use std::sync::Arc;
88
use std::time::Duration;
99

10+
use mithril_common::messages::RegisterSignatureMessageDmq;
11+
use mithril_dmq_node::DmqConsumerPallas;
1012
use mithril_signed_entity_lock::SignedEntityTypeLock;
1113

1214
use crate::database::repository::CertificateRepository;
1315
use crate::dependency_injection::{DependenciesBuilder, Result};
1416
use crate::get_dependency;
1517
use crate::services::{
1618
AggregatorClient, AggregatorHTTPClient, MessageService, MithrilMessageService,
17-
SequentialSignatureProcessor, SignatureConsumer, SignatureConsumerNoop, SignatureProcessor,
19+
SequentialSignatureProcessor, SignatureConsumer, SignatureConsumerDmq, SignatureConsumerNoop,
20+
SignatureProcessor,
1821
};
1922
impl DependenciesBuilder {
2023
async fn build_signed_entity_type_lock(&mut self) -> Result<Arc<SignedEntityTypeLock>> {
@@ -74,9 +77,19 @@ impl DependenciesBuilder {
7477

7578
/// Builds a [SignatureConsumer]
7679
pub async fn build_signature_consumer(&mut self) -> Result<Arc<dyn SignatureConsumer>> {
77-
let signature_consumer = SignatureConsumerNoop;
80+
let signature_consumer =
81+
if let Some(dmq_node_socket_path) = self.configuration.dmq_node_socket_path() {
82+
let dmq_consumer = Arc::new(DmqConsumerPallas::<RegisterSignatureMessageDmq>::new(
83+
dmq_node_socket_path,
84+
self.configuration.get_network()?,
85+
self.root_logger(),
86+
));
87+
Arc::new(SignatureConsumerDmq::new(dmq_consumer)) as Arc<dyn SignatureConsumer>
88+
} else {
89+
Arc::new(SignatureConsumerNoop) as Arc<dyn SignatureConsumer>
90+
};
7891

79-
Ok(Arc::new(signature_consumer))
92+
Ok(signature_consumer)
8093
}
8194

8295
/// Builds a [SignatureProcessor]

0 commit comments

Comments
 (0)