From 84990bb7b6e816a2bdd9f7ae2f5a8c25b1525b38 Mon Sep 17 00:00:00 2001 From: Bryan Stitt Date: Sun, 28 May 2023 22:42:18 -0700 Subject: [PATCH] check hard_limit_until when finding if an rpc will work --- web3_proxy/src/rpcs/consensus.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/web3_proxy/src/rpcs/consensus.rs b/web3_proxy/src/rpcs/consensus.rs index b7237ccb..fd18c349 100644 --- a/web3_proxy/src/rpcs/consensus.rs +++ b/web3_proxy/src/rpcs/consensus.rs @@ -230,6 +230,8 @@ impl ConsensusWeb3Rpcs { } // TODO: better name for this + // TODO: this should probably be on the rpcs as "can_serve_request" + // TODO: this should probably take the method, too pub fn rpc_will_work_now( &self, skip: &[Arc], @@ -264,7 +266,13 @@ impl ConsensusWeb3Rpcs { } } - // we could check hard rate limits here, but i think it is faster to do later + // TODO: this might be a big perf hit. benchmark + if let Some(x) = rpc.hard_limit_until { + if x.borrow() > Instant::now() { + trace!("{} is rate limited. skipping", rpc,); + return false; + } + } true }