From dc6e0559f7d756e0a98270019b060f896e4bdb55 Mon Sep 17 00:00:00 2001 From: Bryan Stitt Date: Sun, 28 May 2023 22:47:39 -0700 Subject: [PATCH] improve will_work_eventually --- web3_proxy/src/rpcs/consensus.rs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/web3_proxy/src/rpcs/consensus.rs b/web3_proxy/src/rpcs/consensus.rs index fd18c349..bde3f2cb 100644 --- a/web3_proxy/src/rpcs/consensus.rs +++ b/web3_proxy/src/rpcs/consensus.rs @@ -196,7 +196,6 @@ impl ConsensusWeb3Rpcs { needed_block_num: Option<&U64>, skip_rpcs: &[Arc], ) -> bool { - // return true if this rpc will never work for us. "false" is good if skip_rpcs.contains(rpc) { // if rpc is skipped, it must have already been determined it is unable to serve the request return false; @@ -206,7 +205,8 @@ impl ConsensusWeb3Rpcs { if let Some(rpc_data) = self.rpc_data.get(rpc) { match rpc_data.head_block_num.cmp(needed_block_num) { Ordering::Less => { - debug!("{} is behind. let it catch up", rpc); + trace!("{} is behind. let it catch up", rpc); + // TODO: what if this is a pruned rpc that is behind by a lot, and the block is old, too? return true; } Ordering::Greater | Ordering::Equal => { @@ -223,10 +223,11 @@ impl ConsensusWeb3Rpcs { } // no rpc data for this rpc. thats not promising - return true; + false + } else { + // if no needed_block_num was specified, then this should work + true } - - false } // TODO: better name for this @@ -267,8 +268,8 @@ impl ConsensusWeb3Rpcs { } // TODO: this might be a big perf hit. benchmark - if let Some(x) = rpc.hard_limit_until { - if x.borrow() > Instant::now() { + if let Some(x) = rpc.hard_limit_until.as_ref() { + if *x.borrow() > Instant::now() { trace!("{} is rate limited. skipping", rpc,); return false; }