From 08859ba04dd54bbe2d136c2592068320ecee0490 Mon Sep 17 00:00:00 2001 From: Bryan Stitt Date: Sun, 28 May 2023 22:37:37 -0700 Subject: [PATCH] wait for consensus rpcs to change before trying again --- web3_proxy/src/rpcs/many.rs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/web3_proxy/src/rpcs/many.rs b/web3_proxy/src/rpcs/many.rs index 4bf536cf..7ad30174 100644 --- a/web3_proxy/src/rpcs/many.rs +++ b/web3_proxy/src/rpcs/many.rs @@ -511,6 +511,7 @@ impl Web3Rpcs { .cloned() .collect(); + // TODO: include tiers in this? potential_rpcs.shuffle(&mut thread_fast_rng::thread_fast_rng()); match self @@ -653,16 +654,21 @@ impl Web3Rpcs { match consensus_rpcs.should_wait_for_block(waiting_for, skip_rpcs) { ShouldWaitForBlock::NeverReady => break, - ShouldWaitForBlock::Ready => {} + ShouldWaitForBlock::Ready => { + if Instant::now() > stop_trying_at { + break; + } + } ShouldWaitForBlock::Wait { .. } => select! { _ = watch_consensus_rpcs.changed() => {}, - _ = sleep_until(stop_trying_at) => {}, + _ = sleep_until(stop_trying_at) => break, }, } - } - - if Instant::now() > stop_trying_at { - break; + } else { + select! { + _ = watch_consensus_rpcs.changed() => {}, + _ = sleep_until(stop_trying_at) => break, + } } } }