diff --git a/nym-wallet/src-tauri/src/config/mod.rs b/nym-wallet/src-tauri/src/config/mod.rs index ed10e3d11b..1299660f61 100644 --- a/nym-wallet/src-tauri/src/config/mod.rs +++ b/nym-wallet/src-tauri/src/config/mod.rs @@ -5,10 +5,7 @@ use crate::{error::BackendError, network::Network as WalletNetwork}; use config::defaults::{all::SupportedNetworks, ValidatorDetails}; use config::NymConfig; use itertools::Itertools; -use reqwest::StatusCode; use serde::{Deserialize, Serialize}; -use std::collections::HashMap; -use std::iter::zip; use std::time::Duration; use std::{fs, io, path::PathBuf}; use strum::IntoEnumIterator; @@ -178,56 +175,6 @@ impl Config { self.base.fetched_validators = serde_json::from_str(&response.text().await?)?; Ok(()) } - - pub async fn check_validator_health( - &self, - network: WalletNetwork, - ) -> Result, BackendError> { - // Limit the number of validators we query - let max_validators = 200_usize; - let validators_to_query = || self.get_validators(network).take(max_validators); - - let validator_urls = validators_to_query().map(|v| { - let mut health_url = v.nymd_url.clone(); - health_url.set_path("health"); - (v, health_url) - }); - - let client = reqwest::Client::builder() - .timeout(Duration::from_secs(3)) - .build()?; - - let requests = validator_urls.map(|(_, url)| client.get(url).send()); - let responses = futures::future::join_all(requests).await; - - let validators_responding_success = - zip(validators_to_query(), responses).filter_map(|(v, r)| match r { - Ok(r) if r.status().is_success() => Some((v, r.status())), - _ => None, - }); - - Ok(validators_responding_success.collect::>()) - } - - #[allow(unused)] - pub async fn check_validator_health_for_all_networks( - &self, - ) -> Result>, BackendError> { - let validator_health_requests = - WalletNetwork::iter().map(|network| self.check_validator_health(network)); - - let responses_keyed_by_network = zip( - WalletNetwork::iter(), - futures::future::join_all(validator_health_requests).await, - ); - - // Iterate and collect manually to be able to return errors in the response - let mut responses = HashMap::new(); - for (network, response) in responses_keyed_by_network { - responses.insert(network, response?); - } - Ok(responses) - } } #[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq, Hash)] @@ -250,26 +197,6 @@ impl TryFrom for ValidatorUrl { } } -#[derive(Clone, Debug)] -pub struct ValidatorUrlWithApiEndpoint { - pub nymd_url: Url, - pub api_url: Url, -} - -impl TryFrom for ValidatorUrlWithApiEndpoint { - type Error = BackendError; - - fn try_from(validator: ValidatorUrl) -> Result { - match validator.api_url { - Some(api_url) => Ok(ValidatorUrlWithApiEndpoint { - nymd_url: validator.nymd_url, - api_url, - }), - None => Err(BackendError::NoValidatorApiUrlConfigured), - } - } -} - #[derive(Debug, Default, Deserialize, Serialize, Clone, PartialEq, Eq)] #[serde(deny_unknown_fields)] struct OptionalValidators {