allow_unhealthy should also skip checking block heights

This commit is contained in:
Bryan Stitt 2023-10-13 20:26:02 -07:00
parent e11e6f6f27
commit ba7eba41db

View File

@ -737,9 +737,19 @@ impl Web3Rpc {
trace!("starting subscriptions on {}", self);
self.check_provider(chain_id)
// start optimistically
// we need healthy to start at "true" or else check_provider and other things will not send requests
// self.healthy.store(true, atomic::Ordering::Relaxed);
// TODO: this should set healthy to false. its not strictly necessary since block checks will fail, but this is a faster check
if let Err(err) = self
.check_provider(chain_id)
.await
.web3_context("failed check_provider")?;
.web3_context("failed check_provider")
{
self.healthy.store(false, atomic::Ordering::Relaxed);
return Err(err);
}
let mut futures = Vec::new();
let mut abort_handles = vec![];
@ -810,8 +820,6 @@ impl Web3Rpc {
tokio::spawn(f)
} else {
self.healthy.store(true, atomic::Ordering::Relaxed);
let rpc = self.clone();
let health_sleep_seconds = 60;
@ -1153,8 +1161,8 @@ impl Web3Rpc {
) -> Web3ProxyResult<OpenRequestResult> {
// TODO: if websocket is reconnecting, return an error?
// TODO: what if this is a health check?!
if !(self.healthy.load(atomic::Ordering::Relaxed) || allow_unhealthy) {
if !allow_unhealthy {
if !(self.healthy.load(atomic::Ordering::Relaxed)) {
return Ok(OpenRequestResult::Failed);
}
@ -1218,6 +1226,7 @@ impl Web3Rpc {
return Ok(OpenRequestResult::Lagged(Box::pin(synced_f)));
}
}
}
// check rate limits
match self.try_throttle().await? {