From f71cec80ed9a42a7ee4cf5e2faa341190a8d944c Mon Sep 17 00:00:00 2001 From: Benno Zeeman Date: Tue, 14 Jan 2025 14:34:51 +0100 Subject: [PATCH] refactor: base evm network on local setting --- autonomi/src/client/mod.rs | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/autonomi/src/client/mod.rs b/autonomi/src/client/mod.rs index 62d19a9dac..72e0d27876 100644 --- a/autonomi/src/client/mod.rs +++ b/autonomi/src/client/mod.rs @@ -71,8 +71,6 @@ pub struct Client { #[derive(Debug, Clone, Default)] pub struct ClientConfig { /// Whether we're expected to connect to a local network. - /// - /// If `local` feature is enabled, [`ClientConfig::default()`] will set this to `true`. pub local: bool, /// List of peers to connect to. @@ -84,15 +82,15 @@ pub struct ClientConfig { pub evm_network: EvmNetwork, } -// impl Default for ClientConfig { -// fn default() -> Self { -// Self { -// local: false, -// peers: None, -// evm_network: EvmNetwork::try_from_env().unwrap_or_default(), -// } -// } -// } +impl ClientConfig { + fn local(peers: Option>) -> Self { + Self { + local: true, + peers, + evm_network: EvmNetwork::new(true).unwrap_or_default(), + } + } +} /// Error returned by [`Client::init`]. #[derive(Debug, thiserror::Error)] @@ -122,11 +120,7 @@ impl Client { /// /// See [`Client::init_with_config`]. pub async fn init_local() -> Result { - Self::init_with_config(ClientConfig { - local: true, - ..Default::default() - }) - .await + Self::init_with_config(ClientConfig::local(None)).await } /// Initialize a client that bootstraps from a list of peers.