From 94089eb72bd85a9b65a92b063bbc122ae99f0760 Mon Sep 17 00:00:00 2001 From: Bryan Stitt Date: Fri, 3 Mar 2023 07:34:04 -0800 Subject: [PATCH] combine comparison --- web3_proxy/src/rpcs/many.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/web3_proxy/src/rpcs/many.rs b/web3_proxy/src/rpcs/many.rs index 64706a1b..9370a1ca 100644 --- a/web3_proxy/src/rpcs/many.rs +++ b/web3_proxy/src/rpcs/many.rs @@ -503,6 +503,7 @@ impl Web3Rpcs { let head_block_num = synced_connections.head_block.number(); let head_block_age = synced_connections.head_block.age(); + // TODO: double check the logic on this. especially if only min is set let needed_blocks_comparison = match (min_block_needed, max_block_needed) { (None, None) => { // no required block given. treat this like the requested the consensus head block @@ -512,15 +513,17 @@ impl Web3Rpcs { (Some(min_block_needed), None) => min_block_needed.cmp(head_block_num), (Some(min_block_needed), Some(max_block_needed)) => { match min_block_needed.cmp(max_block_needed) { - cmp::Ordering::Equal => min_block_needed.cmp(head_block_num), + cmp::Ordering::Less | cmp::Ordering::Equal => { + min_block_needed.cmp(head_block_num) + } cmp::Ordering::Greater => { + // TODO: force a debug log of the original request to see if our logic is wrong? return Err(anyhow::anyhow!( "Invalid blocks bounds requested. min ({}) > max ({})", min_block_needed, max_block_needed - )) + )); } - cmp::Ordering::Less => min_block_needed.cmp(head_block_num), } } };