Skip to content

Commit ad5c2fc

Browse files
committed
remove useless conversion to SignerEpochSettings
1 parent 0247776 commit ad5c2fc

File tree

6 files changed

+9
-121
lines changed

6 files changed

+9
-121
lines changed

internal/mithril-protocol-config/src/http/aggregator_client.rs

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use anyhow::anyhow;
22
use async_trait::async_trait;
3-
use mithril_common::messages::TryFromMessageAdapter;
43
use reqwest::header::{self, HeaderValue};
54
use reqwest::{self, Client, Proxy, RequestBuilder, Response, StatusCode};
65
use semver::Version;
@@ -16,9 +15,6 @@ use mithril_common::{
1615
messages::EpochSettingsMessage,
1716
};
1817

19-
use crate::http::from_epoch_settings::FromEpochSettingsAdapter;
20-
use crate::signer_epoch_settings::SignerEpochSettings;
21-
2218
const JSON_CONTENT_TYPE: HeaderValue = HeaderValue::from_static("application/json");
2319

2420
const API_VERSION_MISMATCH_WARNING_MESSAGE: &str =
@@ -59,10 +55,6 @@ pub enum AggregatorClientError {
5955
#[error("proxy creation failed")]
6056
ProxyCreation(#[source] StdError),
6157

62-
/// Adapter error
63-
#[error("adapter failed")]
64-
Adapter(#[source] StdError),
65-
6658
/// No signer registration round opened yet
6759
#[error("a signer registration round is not opened yet, please try again later")]
6860
RegistrationRoundNotYetOpened(#[source] StdError),
@@ -131,7 +123,7 @@ pub trait AggregatorClient: Sync + Send {
131123
/// Retrieves epoch settings from the aggregator
132124
async fn retrieve_epoch_settings(
133125
&self,
134-
) -> Result<Option<SignerEpochSettings>, AggregatorClientError>;
126+
) -> Result<Option<EpochSettingsMessage>, AggregatorClientError>;
135127
}
136128

137129
/// AggregatorHTTPClient is a http client for an aggregator
@@ -230,7 +222,7 @@ impl AggregatorHTTPClient {
230222
impl AggregatorClient for AggregatorHTTPClient {
231223
async fn retrieve_epoch_settings(
232224
&self,
233-
) -> Result<Option<SignerEpochSettings>, AggregatorClientError> {
225+
) -> Result<Option<EpochSettingsMessage>, AggregatorClientError> {
234226
debug!(self.logger, "Retrieve epoch settings");
235227
let url = format!("{}/epoch-settings", self.aggregator_endpoint);
236228
let response = self
@@ -243,11 +235,7 @@ impl AggregatorClient for AggregatorHTTPClient {
243235
StatusCode::OK => {
244236
self.warn_if_api_version_mismatch(&response);
245237
match response.json::<EpochSettingsMessage>().await {
246-
Ok(message) => {
247-
let epoch_settings = FromEpochSettingsAdapter::try_adapt(message)
248-
.map_err(|e| AggregatorClientError::Adapter(anyhow!(e)))?;
249-
Ok(Some(epoch_settings))
250-
}
238+
Ok(message) => Ok(Some(message)),
251239
Err(err) => Err(AggregatorClientError::JsonParseFailed(anyhow!(err))),
252240
}
253241
}
@@ -269,7 +257,7 @@ pub(crate) mod dumb {
269257
/// It actually does not communicate with an aggregator host but mimics this behavior.
270258
/// It is driven by a Tester that controls the data it can return, and it can return its internal state for testing.
271259
pub struct DumbAggregatorClient {
272-
epoch_settings: RwLock<Option<SignerEpochSettings>>,
260+
epoch_settings: RwLock<Option<EpochSettingsMessage>>,
273261
}
274262

275263
// impl DumbAggregatorClient {
@@ -282,7 +270,7 @@ pub(crate) mod dumb {
282270
impl Default for DumbAggregatorClient {
283271
fn default() -> Self {
284272
Self {
285-
epoch_settings: RwLock::new(Some(SignerEpochSettings::dummy())),
273+
epoch_settings: RwLock::new(Some(EpochSettingsMessage::dummy())),
286274
}
287275
}
288276
}
@@ -291,7 +279,7 @@ pub(crate) mod dumb {
291279
impl AggregatorClient for DumbAggregatorClient {
292280
async fn retrieve_epoch_settings(
293281
&self,
294-
) -> Result<Option<SignerEpochSettings>, AggregatorClientError> {
282+
) -> Result<Option<EpochSettingsMessage>, AggregatorClientError> {
295283
let epoch_settings = self.epoch_settings.read().await.clone();
296284

297285
Ok(epoch_settings)
@@ -389,10 +377,7 @@ mod tests {
389377

390378
let epoch_settings = client.retrieve_epoch_settings().await;
391379
epoch_settings.as_ref().expect("unexpected error");
392-
assert_eq!(
393-
FromEpochSettingsAdapter::try_adapt(epoch_settings_expected).unwrap(),
394-
epoch_settings.unwrap().unwrap()
395-
);
380+
assert_eq!(epoch_settings_expected, epoch_settings.unwrap().unwrap());
396381
}
397382

398383
#[tokio::test]

internal/mithril-protocol-config/src/http/from_epoch_settings.rs

Lines changed: 0 additions & 42 deletions
This file was deleted.

internal/mithril-protocol-config/src/http/http_impl.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ impl MithrilNetworkConfigurationProvider for HttpMithrilNetworkConfigurationProv
5151
Ok(MithrilNetworkConfiguration {
5252
epoch: epoch_settings.epoch,
5353
signer_registration_protocol_parameters: epoch_settings
54-
.registration_protocol_parameters,
55-
available_signed_entity_types, // To be implemented
54+
.signer_registration_protocol_parameters,
55+
available_signed_entity_types,
5656
signed_entity_types_config,
5757
})
5858
}
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
mod aggregator_client;
2-
mod from_epoch_settings;
32
mod http_impl;

internal/mithril-protocol-config/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ const HTTP_REQUEST_TIMEOUT_DURATION: u64 = 30000;
33
pub mod http;
44
pub mod interface;
55
pub mod model;
6-
pub mod signer_epoch_settings;
76

87
#[cfg(test)]
98
pub(crate) mod test_tools {

internal/mithril-protocol-config/src/signer_epoch_settings.rs

Lines changed: 0 additions & 53 deletions
This file was deleted.

0 commit comments

Comments
 (0)