From 5367c511953fcea1af3da1d905de06d9e76711ba Mon Sep 17 00:00:00 2001 From: Bryan Stitt Date: Sat, 17 Jun 2023 12:09:04 -0700 Subject: [PATCH] temp fix while filtering is improved --- web3_proxy/src/rpcs/many.rs | 3 ++- web3_proxy/src/rpcs/one.rs | 12 ++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/web3_proxy/src/rpcs/many.rs b/web3_proxy/src/rpcs/many.rs index 21db4d8e..b9f6d9f9 100644 --- a/web3_proxy/src/rpcs/many.rs +++ b/web3_proxy/src/rpcs/many.rs @@ -1437,7 +1437,8 @@ mod tests { let names_in_sort_order: Vec<_> = rpcs.iter().map(|x| x.name.as_str()).collect(); - assert_eq!(names_in_sort_order, ["c", "b", "a", "f", "e", "d"]); + // 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"]); } #[tokio::test(start_paused = true)] diff --git a/web3_proxy/src/rpcs/one.rs b/web3_proxy/src/rpcs/one.rs index 679788d4..2723d75e 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 - /// - tier (ascending) /// - block number (descending) + /// - tier (ascending) /// TODO: tests on this! - /// TODO: should tier or block number take priority? + /// 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 this return a struct that implements sorting traits? - fn sort_on(&self, max_block: Option) -> (bool, u32, Reverse) { + fn sort_on(&self, max_block: Option) -> (bool, Reverse, u32) { let mut head_block = self .head_block .as_ref() @@ -253,13 +253,13 @@ impl Web3Rpc { let backup = self.backup; - (!backup, tier, Reverse(head_block)) + (!backup, Reverse(head_block), tier) } pub fn sort_for_load_balancing_on( &self, max_block: Option, - ) -> ((bool, u32, Reverse), OrderedFloat) { + ) -> ((bool, Reverse, u32), 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, u32, Reverse), u8) { + ) -> ((bool, Reverse, u32), u8) { let sort_on = self.sort_on(max_block); let mut rng = nanorand::tls_rng();