From 8b22c9861be7fd6b9f262b14e8d75a0b8fd2952f Mon Sep 17 00:00:00 2001 From: Bryan Stitt Date: Sat, 17 Jun 2023 12:15:40 -0700 Subject: [PATCH] Revert "temp fix while filtering is improved" This reverts commit 5367c511953fcea1af3da1d905de06d9e76711ba. --- web3_proxy/src/rpcs/many.rs | 3 +-- web3_proxy/src/rpcs/one.rs | 12 ++++++------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/web3_proxy/src/rpcs/many.rs b/web3_proxy/src/rpcs/many.rs index b9f6d9f9..21db4d8e 100644 --- a/web3_proxy/src/rpcs/many.rs +++ b/web3_proxy/src/rpcs/many.rs @@ -1437,8 +1437,7 @@ mod tests { let names_in_sort_order: Vec<_> = rpcs.iter().map(|x| x.name.as_str()).collect(); - // TODO: if we prioritize tier over block_num, this is:["c", "b", "a", "f", "e", "d"] - assert_eq!(names_in_sort_order, ["c", "f", "b", "e", "a", "d"]); + assert_eq!(names_in_sort_order, ["c", "b", "a", "f", "e", "d"]); } #[tokio::test(start_paused = true)] diff --git a/web3_proxy/src/rpcs/one.rs b/web3_proxy/src/rpcs/one.rs index 2723d75e..679788d4 100644 --- a/web3_proxy/src/rpcs/one.rs +++ b/web3_proxy/src/rpcs/one.rs @@ -233,12 +233,12 @@ impl Web3Rpc { /// sort by... /// - backups last - /// - block number (descending) /// - tier (ascending) + /// - block number (descending) /// TODO: tests on this! - /// TODO: should tier or block number take priority? it depends on the request. need to make sure filtering is right and then it should work tier before block_number + /// TODO: should tier or block number take priority? /// TODO: should this return a struct that implements sorting traits? - fn sort_on(&self, max_block: Option) -> (bool, Reverse, u32) { + fn sort_on(&self, max_block: Option) -> (bool, u32, Reverse) { let mut head_block = self .head_block .as_ref() @@ -253,13 +253,13 @@ impl Web3Rpc { let backup = self.backup; - (!backup, Reverse(head_block), tier) + (!backup, tier, Reverse(head_block)) } pub fn sort_for_load_balancing_on( &self, max_block: Option, - ) -> ((bool, Reverse, u32), OrderedFloat) { + ) -> ((bool, u32, Reverse), OrderedFloat) { let sort_on = self.sort_on(max_block); let weighted_peak_ewma_seconds = self.weighted_peak_ewma_seconds(); @@ -275,7 +275,7 @@ impl Web3Rpc { pub fn shuffle_for_load_balancing_on( &self, max_block: Option, - ) -> ((bool, Reverse, u32), u8) { + ) -> ((bool, u32, Reverse), u8) { let sort_on = self.sort_on(max_block); let mut rng = nanorand::tls_rng();