From db528f00900ae82c826005c78ef29dec7b5c1354 Mon Sep 17 00:00:00 2001 From: sergey-melnychuk <8093171+sergey-melnychuk@users.noreply.github.com> Date: Sat, 24 Feb 2024 20:05:23 +0100 Subject: [PATCH] chore: extract method `to_helios_client_builder` --- crates/core/src/config.rs | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/crates/core/src/config.rs b/crates/core/src/config.rs index 0af477d7..248e1043 100644 --- a/crates/core/src/config.rs +++ b/crates/core/src/config.rs @@ -167,13 +167,11 @@ impl Config { JsonRpcClient::new(transport) } - #[cfg(not(target_arch = "wasm32"))] - pub async fn to_helios_client(&self) -> Client { + async fn to_helios_client_builder(&self) -> ClientBuilder { let consensus_rpc = self.get_consensus_rpc().expect("unable to retrieve consensus url"); ClientBuilder::new() .network(self.network) - .data_dir(self.data_dir.clone()) .consensus_rpc(&consensus_rpc) .execution_rpc(&self.eth_execution_rpc) .checkpoint( @@ -184,24 +182,21 @@ impl Config { ) .load_external_fallback() .fallback(&consensus_rpc) + } + + #[cfg(not(target_arch = "wasm32"))] + pub async fn to_helios_client(&self) -> Client { + self.to_helios_client_builder() + .await + .data_dir(self.data_dir.clone()) .build() .expect("incorrect helios client config") } #[cfg(target_arch = "wasm32")] pub async fn to_helios_client(&self) -> Client { - ClientBuilder::new() - .network(self.network) - .consensus_rpc(&self.get_consensus_rpc()) - .execution_rpc(&self.eth_execution_rpc) - .checkpoint( - &self - .get_checkpoint() - .await - .expect("unable to retrieve checkpoint"), - ) - .load_external_fallback() - .fallback(&self.get_consensus_rpc()) + self.to_helios_client_builder() + .await .build() .expect("incorrect helios client config") }