From 02ba07af625e7527e3f5179ad89b17ab330e7ced Mon Sep 17 00:00:00 2001 From: Dadepo Aderemi Date: Sun, 26 May 2024 12:19:23 +0400 Subject: [PATCH] Removed unnecessary async wrapper --- src/client.rs | 64 +++++++++++++++++++++++++-------------------------- 1 file changed, 32 insertions(+), 32 deletions(-) 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;