Skip to content

Commit

Permalink
chore: extract method to_helios_client_builder
Browse files Browse the repository at this point in the history
  • Loading branch information
sergey-melnychuk committed Feb 26, 2024
1 parent abad588 commit db528f0
Showing 1 changed file with 10 additions and 15 deletions.
25 changes: 10 additions & 15 deletions crates/core/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,11 @@ impl Config {
JsonRpcClient::new(transport)
}

#[cfg(not(target_arch = "wasm32"))]
pub async fn to_helios_client(&self) -> Client<FileDB> {
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(
Expand All @@ -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<FileDB> {
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<ConfigDB> {
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")
}
Expand Down

0 comments on commit db528f0

Please sign in to comment.