prioritize block. queries to syncing nodes ends up being slower
This commit is contained in:
parent
ac4b7e46b4
commit
30828ccae2
@ -64,12 +64,12 @@ impl RpcRanking {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn sort_key(&self) -> (bool, u32, Reverse<Option<U64>>) {
|
fn sort_key(&self) -> (bool, Reverse<Option<U64>>, u32) {
|
||||||
// TODO: add soft_limit here? add peak_ewma here?
|
// TODO: add soft_limit here? add peak_ewma here?
|
||||||
// TODO: should backup or tier be checked first? now that tiers are automated, backups
|
// TODO: should backup or tier be checked first? now that tiers are automated, backups
|
||||||
// TODO: should we include a random number in here?
|
// TODO: should we include a random number in here?
|
||||||
// TODO: should we include peak_ewma_latency or weighted_peak_ewma_latency?
|
// TODO: should we include peak_ewma_latency or weighted_peak_ewma_latency?
|
||||||
(!self.backup, self.tier, Reverse(self.head_num))
|
(!self.backup, Reverse(self.head_num), self.tier)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -855,12 +855,8 @@ impl ConsensusFinder {
|
|||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|(block, (rpc_names, sum_soft_limit))| (block, sum_soft_limit, rpc_names))
|
.map(|(block, (rpc_names, sum_soft_limit))| (block, sum_soft_limit, rpc_names))
|
||||||
.collect();
|
.collect();
|
||||||
votes.sort_by_cached_key(|(block, sum_soft_limit, rpc_names)| {
|
votes.sort_by_key(|(block, sum_soft_limit, _)| {
|
||||||
(
|
(Reverse(*block.number()), Reverse(*sum_soft_limit))
|
||||||
Reverse(*block.number()),
|
|
||||||
Reverse(*sum_soft_limit),
|
|
||||||
Reverse(rpc_names.len()),
|
|
||||||
)
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// return the first result that exceededs confgured minimums (if any)
|
// return the first result that exceededs confgured minimums (if any)
|
||||||
|
@ -1485,7 +1485,8 @@ mod tests {
|
|||||||
|
|
||||||
let names_in_sort_order: Vec<_> = rpcs.iter().map(|x| x.name.as_str()).collect();
|
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"]);
|
// assert_eq!(names_in_sort_order, ["c", "b", "a", "f", "e", "d"]);
|
||||||
|
assert_eq!(names_in_sort_order, ["c", "f", "b", "e", "a", "d"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test(start_paused = true)]
|
#[tokio::test(start_paused = true)]
|
||||||
|
@ -244,7 +244,7 @@ impl Web3Rpc {
|
|||||||
/// TODO: tests on this!
|
/// TODO: tests on this!
|
||||||
/// TODO: should tier or block number take priority?
|
/// TODO: should tier or block number take priority?
|
||||||
/// TODO: should this return a struct that implements sorting traits?
|
/// TODO: should this return a struct that implements sorting traits?
|
||||||
fn sort_on(&self, max_block: Option<U64>) -> (bool, u32, Reverse<U64>) {
|
fn sort_on(&self, max_block: Option<U64>) -> (bool, Reverse<U64>, u32) {
|
||||||
let mut head_block = self
|
let mut head_block = self
|
||||||
.head_block
|
.head_block
|
||||||
.as_ref()
|
.as_ref()
|
||||||
@ -259,13 +259,13 @@ impl Web3Rpc {
|
|||||||
|
|
||||||
let backup = self.backup;
|
let backup = self.backup;
|
||||||
|
|
||||||
(!backup, tier, Reverse(head_block))
|
(!backup, Reverse(head_block), tier)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn sort_for_load_balancing_on(
|
pub fn sort_for_load_balancing_on(
|
||||||
&self,
|
&self,
|
||||||
max_block: Option<U64>,
|
max_block: Option<U64>,
|
||||||
) -> ((bool, u32, Reverse<U64>), Duration) {
|
) -> ((bool, Reverse<U64>, u32), Duration) {
|
||||||
let sort_on = self.sort_on(max_block);
|
let sort_on = self.sort_on(max_block);
|
||||||
|
|
||||||
let weighted_peak_latency = self.weighted_peak_latency();
|
let weighted_peak_latency = self.weighted_peak_latency();
|
||||||
@ -281,7 +281,7 @@ impl Web3Rpc {
|
|||||||
pub fn shuffle_for_load_balancing_on(
|
pub fn shuffle_for_load_balancing_on(
|
||||||
&self,
|
&self,
|
||||||
max_block: Option<U64>,
|
max_block: Option<U64>,
|
||||||
) -> ((bool, u32, Reverse<U64>), u8) {
|
) -> ((bool, Reverse<U64>, u32), u8) {
|
||||||
let sort_on = self.sort_on(max_block);
|
let sort_on = self.sort_on(max_block);
|
||||||
|
|
||||||
let mut rng = nanorand::tls_rng();
|
let mut rng = nanorand::tls_rng();
|
||||||
|
Loading…
Reference in New Issue
Block a user