From 3928496be57a480ec9e4f9fcff4b2932ce6fdd09 Mon Sep 17 00:00:00 2001 From: Bryan Stitt Date: Fri, 16 Jun 2023 10:52:13 -0700 Subject: [PATCH] start tiers at 1 --- web3_proxy/src/rpcs/blockchain.rs | 4 ++-- web3_proxy/src/rpcs/consensus.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/web3_proxy/src/rpcs/blockchain.rs b/web3_proxy/src/rpcs/blockchain.rs index cea3b749..8913808b 100644 --- a/web3_proxy/src/rpcs/blockchain.rs +++ b/web3_proxy/src/rpcs/blockchain.rs @@ -470,8 +470,8 @@ impl Web3Rpcs { let watch_consensus_head_sender = self.watch_consensus_head_sender.as_ref().unwrap(); let consensus_tier = new_consensus_rpcs.tier; - // TODO: think more about this unwrap - let total_tiers = consensus_finder.worst_tier().unwrap_or(10); + // TODO: think more about the default for total_tiers + let total_tiers = consensus_finder.worst_tier().unwrap_or_default(); let backups_needed = new_consensus_rpcs.backups_needed; let consensus_head_block = new_consensus_rpcs.head_block.clone(); let num_consensus_rpcs = new_consensus_rpcs.num_consensus_rpcs(); diff --git a/web3_proxy/src/rpcs/consensus.rs b/web3_proxy/src/rpcs/consensus.rs index f4f18332..7ff5e3b2 100644 --- a/web3_proxy/src/rpcs/consensus.rs +++ b/web3_proxy/src/rpcs/consensus.rs @@ -500,7 +500,7 @@ impl ConsensusFinder { for (rpc, weighted_latency_ms) in weighted_latencies.into_iter() { let tier = (weighted_latency_ms - min_latency) as f64 / divisor; - let tier = tier.floor() as u32; + let tier = (tier.floor() as u32).saturating_add(1); // TODO: this should be trace trace!(