From c0b457cec8c0cfbddad20f9273402a9914bf6bf1 Mon Sep 17 00:00:00 2001 From: Bryan Stitt Date: Tue, 20 Dec 2022 21:47:41 -0800 Subject: [PATCH] fix allow_not_ready --- web3_proxy/src/frontend/status.rs | 2 +- web3_proxy/src/rpcs/connections.rs | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/web3_proxy/src/frontend/status.rs b/web3_proxy/src/frontend/status.rs index f8853821..5c1a1423 100644 --- a/web3_proxy/src/frontend/status.rs +++ b/web3_proxy/src/frontend/status.rs @@ -14,7 +14,7 @@ use std::sync::Arc; /// Health check page for load balancers to use. #[debug_handler] pub async fn health(Extension(app): Extension>) -> impl IntoResponse { - // TODO: also check that the head block is not too old + // TODO: add a check that we aren't shutting down if app.balanced_rpcs.synced() { (StatusCode::OK, "OK") } else { diff --git a/web3_proxy/src/rpcs/connections.rs b/web3_proxy/src/rpcs/connections.rs index f33362d2..3598d290 100644 --- a/web3_proxy/src/rpcs/connections.rs +++ b/web3_proxy/src/rpcs/connections.rs @@ -483,7 +483,10 @@ impl Web3Connections { // now that the rpcs are sorted, try to get an active request handle for one of them for best_rpc in sorted_rpcs.into_iter() { // increment our connection counter - match best_rpc.try_request_handle(authorization, false).await { + match best_rpc + .try_request_handle(authorization, min_block_needed.is_none()) + .await + { Ok(OpenRequestResult::Handle(handle)) => { trace!("opened handle: {}", best_rpc); return Ok(OpenRequestResult::Handle(handle)); @@ -551,7 +554,10 @@ impl Web3Connections { } // check rate limits and increment our connection counter - match connection.try_request_handle(authorization, false).await { + match connection + .try_request_handle(authorization, block_needed.is_none()) + .await + { Ok(OpenRequestResult::RetryAt(retry_at)) => { // this rpc is not available. skip it earliest_retry_at = earliest_retry_at.min(Some(retry_at));