Require one valid endpoint

This commit is contained in:
dynco-nym
2026-01-28 14:11:50 +01:00
parent f19b891b3c
commit 3ba5e2aa72
2 changed files with 13 additions and 4 deletions
+1 -1
View File
@@ -161,7 +161,7 @@ impl Socks5Args {
None,
self.socks5_json_rpc_url_list.clone(),
)?;
client.ensure_endpoints_work().await?;
client.ensure_endpoint_works().await?;
Ok(())
}
@@ -116,12 +116,21 @@ impl JsonRpcClient {
}
}
pub async fn ensure_endpoints_work(&self) -> anyhow::Result<()> {
pub async fn ensure_endpoint_works(&self) -> anyhow::Result<()> {
let mut any_works = false;
for endpoint in self.test_endpoints.iter() {
self.eth_chainid(endpoint).await?;
if let Err(err) = self.eth_chainid(endpoint).await {
warn!("Endpoint {endpoint} error: {err}");
} else {
any_works = true;
}
}
Ok(())
if any_works {
return Ok(());
} else {
bail!("None of the endpoints are valid, see logs");
};
}
}