allow_unhealthy should also skip checking block heights
This commit is contained in:
parent
e11e6f6f27
commit
ba7eba41db
|
@ -737,9 +737,19 @@ impl Web3Rpc {
|
||||||
|
|
||||||
trace!("starting subscriptions on {}", self);
|
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
|
.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 futures = Vec::new();
|
||||||
let mut abort_handles = vec![];
|
let mut abort_handles = vec![];
|
||||||
|
@ -810,8 +820,6 @@ impl Web3Rpc {
|
||||||
|
|
||||||
tokio::spawn(f)
|
tokio::spawn(f)
|
||||||
} else {
|
} else {
|
||||||
self.healthy.store(true, atomic::Ordering::Relaxed);
|
|
||||||
|
|
||||||
let rpc = self.clone();
|
let rpc = self.clone();
|
||||||
let health_sleep_seconds = 60;
|
let health_sleep_seconds = 60;
|
||||||
|
|
||||||
|
@ -1153,8 +1161,8 @@ impl Web3Rpc {
|
||||||
) -> Web3ProxyResult<OpenRequestResult> {
|
) -> Web3ProxyResult<OpenRequestResult> {
|
||||||
// TODO: if websocket is reconnecting, return an error?
|
// TODO: if websocket is reconnecting, return an error?
|
||||||
|
|
||||||
// TODO: what if this is a health check?!
|
if !allow_unhealthy {
|
||||||
if !(self.healthy.load(atomic::Ordering::Relaxed) || allow_unhealthy) {
|
if !(self.healthy.load(atomic::Ordering::Relaxed)) {
|
||||||
return Ok(OpenRequestResult::Failed);
|
return Ok(OpenRequestResult::Failed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1218,6 +1226,7 @@ impl Web3Rpc {
|
||||||
return Ok(OpenRequestResult::Lagged(Box::pin(synced_f)));
|
return Ok(OpenRequestResult::Lagged(Box::pin(synced_f)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// check rate limits
|
// check rate limits
|
||||||
match self.try_throttle().await? {
|
match self.try_throttle().await? {
|
||||||
|
|
Loading…
Reference in New Issue