diff --git a/web3_proxy/src/rpcs/one.rs b/web3_proxy/src/rpcs/one.rs index f0b03127..3408bb6f 100644 --- a/web3_proxy/src/rpcs/one.rs +++ b/web3_proxy/src/rpcs/one.rs @@ -239,13 +239,13 @@ impl Web3Rpc { } /// sort by... - /// - backups last - /// - tier (ascending) - /// - block number (descending) + /// - tier (ascending. fastest servers first) + /// - backups (primary servers first) + /// - block number (descending. synced servers first) /// TODO: tests on this! /// 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, u32, Reverse) { + fn sort_on(&self, max_block: Option) -> (u32, bool, Reverse) { let mut head_block = self .head_block .as_ref() @@ -260,13 +260,13 @@ impl Web3Rpc { let backup = self.backup; - (!backup, tier, Reverse(head_block)) + (tier, !backup, Reverse(head_block)) } pub fn sort_for_load_balancing_on( &self, max_block: Option, - ) -> ((bool, u32, Reverse), OrderedFloat) { + ) -> ((u32, bool, Reverse), OrderedFloat) { let sort_on = self.sort_on(max_block); let weighted_peak_ewma_seconds = self.weighted_peak_ewma_seconds(); @@ -282,7 +282,7 @@ impl Web3Rpc { pub fn shuffle_for_load_balancing_on( &self, max_block: Option, - ) -> ((bool, u32, Reverse), u8) { + ) -> ((u32, bool, Reverse), u8) { let sort_on = self.sort_on(max_block); let mut rng = nanorand::tls_rng();