connect_networks: Consider providers that timeout as broken
@@ -531,7 +531,6 @@ async fn connect_networks(
network: String,
provider: String,
},
- NoVersion,
Version {
network: String,
ident: EthereumNetworkIdentifier,
@@ -547,33 +546,25 @@ async fn connect_networks(
.map(|(network_name, capabilities, eth_adapter)| {
(network_name, capabilities, eth_adapter, logger.clone())
})
- .map(
- |(network, capabilities, eth_adapter, logger)| async move {
- let logger = logger.new(
- o!("provider" => eth_adapter.provider().to_string()),
- );
+ .map(|(network, capabilities, eth_adapter, logger)| async move {
+ let logger = logger.new(o!("provider" => eth_adapter.provider().to_string()));
info!(
logger, "Connecting to Ethereum to get network identifier";
"capabilities" => &capabilities
);
- match tokio::time::timeout(
- ETH_NET_VERSION_WAIT_TIME,
- eth_adapter.net_identifiers(),
- )
+ match tokio::time::timeout(ETH_NET_VERSION_WAIT_TIME, eth_adapter.net_identifiers())
.await
+ .map_err(Error::from)
{
- // the client didn't respond fast enough. Try to
- // continue without knowing the net version
- Err(_) => {
- warn!(logger, "Provider did not respond fast enough. Continuing without checking for change in net version");
- Status::NoVersion
- },
- // we got some other error (maybe a typo on the URL)
- // still continue with startup
- Ok(Err(e)) => {
+ // An `Err` means a timeout, an `Ok(Err)` means some other error (maybe a typo
+ // on the URL)
+ Ok(Err(e)) | Err(e) => {
error!(logger, "Connection to provider failed. Not using this provider";
"error" => e.to_string());
- Status::Broken { network, provider: eth_adapter.provider().to_string() }
+ Status::Broken {
+ network,
+ provider: eth_adapter.provider().to_string(),
+ }
}
Ok(Ok(ident)) => {
info!(
@@ -585,8 +576,7 @@ async fn connect_networks(
Status::Version { network, ident }
}
}
- },
- ),
+ }),
)
.await;
@@ -602,7 +592,6 @@ async fn connect_networks(
Status::Version { network, ident } => {
networks.entry(network.to_string()).or_default().push(ident)
}
- Status::NoVersion => { /* ignore */ }
}
networks
});
