Skip to content

Commit 11709aa

Browse files
committed
refactor(aggregator): use new shared aggregator client
instead of an internal, copied and adapted over the signer, implementation
1 parent a646200 commit 11709aa

File tree

6 files changed

+35
-1013
lines changed

6 files changed

+35
-1013
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mithril-aggregator/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ flate2 = "1.1.4"
2626
gcloud-kms = { version = "1.3.1", features = ["auth"] }
2727
gcloud-storage = { version = "1.1.1", features = ["auth"] }
2828
hex = { workspace = true }
29+
mithril-aggregator-client = { path = "../internal/mithril-aggregator-client" }
2930
mithril-cardano-node-chain = { path = "../internal/cardano-node/mithril-cardano-node-chain" }
3031
mithril-cardano-node-internal-database = { path = "../internal/cardano-node/mithril-cardano-node-internal-database" }
3132
mithril-cli-helper = { path = "../internal/mithril-cli-helper" }

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

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44
//! - group these enablers into more logical categories
55
//! - redefine the actual categories so those miscellaneous enablers fit into them
66
7-
use anyhow::{Context, anyhow};
8-
use reqwest::Url;
7+
use anyhow::anyhow;
98
use std::sync::Arc;
109
use std::time::Duration;
1110

11+
use mithril_aggregator_client::AggregatorHttpClient;
12+
use mithril_common::logging::LoggerExtensions;
1213
#[cfg(feature = "future_dmq")]
1314
use mithril_common::messages::RegisterSignatureMessageDmq;
1415
#[cfg(feature = "future_dmq")]
@@ -21,9 +22,10 @@ use crate::get_dependency;
2122
#[cfg(feature = "future_dmq")]
2223
use crate::services::SignatureConsumerDmq;
2324
use crate::services::{
24-
AggregatorHTTPClient, MessageService, MithrilMessageService, SequentialSignatureProcessor,
25-
SignatureConsumer, SignatureConsumerNoop, SignatureProcessor,
25+
MessageService, MithrilMessageService, SequentialSignatureProcessor, SignatureConsumer,
26+
SignatureConsumerNoop, SignatureProcessor,
2627
};
28+
2729
impl DependenciesBuilder {
2830
async fn build_signed_entity_type_lock(&mut self) -> Result<Arc<SignedEntityTypeLock>> {
2931
let signed_entity_lock = Arc::new(SignedEntityTypeLock::default());
@@ -60,29 +62,23 @@ impl DependenciesBuilder {
6062
get_dependency!(self.message_service)
6163
}
6264

63-
/// Builds an [AggregatorHTTPClient]
64-
pub async fn build_leader_aggregator_client(&mut self) -> Result<Arc<AggregatorHTTPClient>> {
65+
/// Builds an [AggregatorHttpClient]
66+
pub async fn build_leader_aggregator_client(&mut self) -> Result<Arc<AggregatorHttpClient>> {
6567
let leader_aggregator_endpoint = self.configuration.leader_aggregator_endpoint().ok_or(
6668
anyhow!("Leader Aggregator endpoint is mandatory for follower Aggregator"),
6769
)?;
6870

69-
let aggregator_client = AggregatorHTTPClient::new(
70-
Url::parse(&leader_aggregator_endpoint).with_context(|| {
71-
format!(
72-
"Failed to parse leader aggregator endpoint: '{leader_aggregator_endpoint}'"
73-
)
74-
})?,
75-
None,
76-
self.get_api_version_provider().await?,
77-
Some(Duration::from_secs(30)),
78-
self.root_logger(),
79-
);
71+
let aggregator_client = AggregatorHttpClient::builder(&leader_aggregator_endpoint)
72+
.with_api_version_provider(self.get_api_version_provider().await?)
73+
.with_timeout(Duration::from_secs(30))
74+
.with_logger(self.root_logger.new_with_name("LeaderAggregatorClient"))
75+
.build()?;
8076

8177
Ok(Arc::new(aggregator_client))
8278
}
8379

84-
/// Returns a leader [AggregatorHTTPClient]
85-
pub async fn get_leader_aggregator_client(&mut self) -> Result<Arc<AggregatorHTTPClient>> {
80+
/// Returns a leader [AggregatorHttpClient]
81+
pub async fn get_leader_aggregator_client(&mut self) -> Result<Arc<AggregatorHttpClient>> {
8682
get_dependency!(self.leader_aggregator_client)
8783
}
8884

mithril-aggregator/src/dependency_injection/builder/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use tokio::{
1515
};
1616
use warp::Filter;
1717

18+
use mithril_aggregator_client::AggregatorHttpClient;
1819
use mithril_cardano_node_chain::{
1920
chain_observer::{CardanoCliRunner, ChainObserver},
2021
chain_reader::ChainBlockReader,
@@ -56,7 +57,7 @@ use crate::{
5657
file_uploaders::FileUploader,
5758
http_server::routes::router::{self, RouterConfig, RouterState},
5859
services::{
59-
AggregatorHTTPClient, CertificateChainSynchronizer, CertifierService, MessageService,
60+
CertificateChainSynchronizer, CertifierService, MessageService,
6061
MithrilSignerRegistrationFollower, ProverService, SignedEntityService, SignerSynchronizer,
6162
Snapshotter, StakeDistributionService, UpkeepService,
6263
},
@@ -278,7 +279,7 @@ pub struct DependenciesBuilder {
278279
pub metrics_service: Option<Arc<MetricsService>>,
279280

280281
/// Leader aggregator client
281-
pub leader_aggregator_client: Option<Arc<AggregatorHTTPClient>>,
282+
pub leader_aggregator_client: Option<Arc<AggregatorHttpClient>>,
282283

283284
/// Protocol parameters retriever
284285
pub protocol_parameters_retriever: Option<Arc<dyn ProtocolParametersRetriever>>,

0 commit comments

Comments
 (0)