if not watching heads, send to any server
This commit is contained in:
parent
f3435bc6e0
commit
3621d71037
@ -492,6 +492,24 @@ impl Web3Rpcs {
|
|||||||
max_block_needed: Option<&U64>,
|
max_block_needed: Option<&U64>,
|
||||||
) -> anyhow::Result<OpenRequestResult> {
|
) -> anyhow::Result<OpenRequestResult> {
|
||||||
let usable_rpcs_by_tier_and_head_number: BTreeMap<(u64, Option<U64>), Vec<Arc<Web3Rpc>>> = {
|
let usable_rpcs_by_tier_and_head_number: BTreeMap<(u64, Option<U64>), Vec<Arc<Web3Rpc>>> = {
|
||||||
|
if self.watch_consensus_head_sender.is_none() {
|
||||||
|
// pick any server
|
||||||
|
let mut m = BTreeMap::new();
|
||||||
|
|
||||||
|
let key = (0, None);
|
||||||
|
|
||||||
|
for x in self.by_name.read().values() {
|
||||||
|
if skip.contains(x) {
|
||||||
|
trace!("skipping: {}", x);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
trace!("not skipped!");
|
||||||
|
|
||||||
|
m.entry(key).or_insert_with(Vec::new).push(x.clone());
|
||||||
|
}
|
||||||
|
|
||||||
|
m
|
||||||
|
} else {
|
||||||
let synced_connections = self.watch_consensus_rpcs_sender.borrow().clone();
|
let synced_connections = self.watch_consensus_rpcs_sender.borrow().clone();
|
||||||
|
|
||||||
if synced_connections.is_none() {
|
if synced_connections.is_none() {
|
||||||
@ -542,7 +560,8 @@ impl Web3Rpcs {
|
|||||||
|
|
||||||
let min_block_age =
|
let min_block_age =
|
||||||
self.max_block_age.map(|x| head_block_age.saturating_sub(x));
|
self.max_block_age.map(|x| head_block_age.saturating_sub(x));
|
||||||
let min_sync_num = self.max_block_lag.map(|x| head_block_num.saturating_sub(x));
|
let min_sync_num =
|
||||||
|
self.max_block_lag.map(|x| head_block_num.saturating_sub(x));
|
||||||
|
|
||||||
// TODO: cache this somehow?
|
// TODO: cache this somehow?
|
||||||
// TODO: maybe have a helper on synced_connections? that way sum_soft_limits/min_synced_rpcs will be DRY
|
// TODO: maybe have a helper on synced_connections? that way sum_soft_limits/min_synced_rpcs will be DRY
|
||||||
@ -628,6 +647,7 @@ impl Web3Rpcs {
|
|||||||
}
|
}
|
||||||
|
|
||||||
m
|
m
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
trace!(
|
trace!(
|
||||||
|
Loading…
Reference in New Issue
Block a user