diff --git a/src/client.rs b/src/client.rs index 5a5188e..16adbea 100644 --- a/src/client.rs +++ b/src/client.rs @@ -62,7 +62,10 @@ pub struct EndpointsConfig { } pub trait HttpClient { - fn send_request(&self, path: String) -> impl std::future::Future> + Send; + fn send_request( + &self, + path: String, + ) -> impl std::future::Future> + Send; } impl HttpClient for reqwest::Client { @@ -99,41 +102,38 @@ impl CheckpointClient { )?; let results = join_all(endpoints.iter().map(|endpoint| async { - async { - let path = format!( - "{}/eth/v1/beacon/states/{}/finality_checkpoints", - endpoint.clone(), - self.state_id - ); - let result = self.client.send_request(path); - match result.await { - Ok(res) => { - if res.status().is_success() { - ResponsePayloadWithEndpointInfo { - payload: res - .json::() - .await - .map_err(|e| AppError::EndpointResponseError(e.to_string())), - endpoint: endpoint.clone(), - } - } else { - ResponsePayloadWithEndpointInfo { - payload: Err(AppError::EndpointResponseError(format!( - "Error with calling {} status code {}", - endpoint.clone(), - res.status() - ))), - endpoint: endpoint.clone(), - } + let path = format!( + "{}/eth/v1/beacon/states/{}/finality_checkpoints", + endpoint.clone(), + self.state_id + ); + let result = self.client.send_request(path).await; + match result { + Ok(res) => { + if res.status().is_success() { + ResponsePayloadWithEndpointInfo { + payload: res + .json::() + .await + .map_err(|e| AppError::EndpointResponseError(e.to_string())), + endpoint: endpoint.clone(), + } + } else { + ResponsePayloadWithEndpointInfo { + payload: Err(AppError::EndpointResponseError(format!( + "Error with calling {} status code {}", + endpoint.clone(), + res.status() + ))), + endpoint: endpoint.clone(), } } - Err(e) => ResponsePayloadWithEndpointInfo { - payload: Err(e), - endpoint: endpoint.clone(), - }, } + Err(e) => ResponsePayloadWithEndpointInfo { + payload: Err(e), + endpoint: endpoint.clone(), + }, } - .await })) .await;