skip nodes that are syncing
This commit is contained in:
parent
eb4b487aae
commit
b8ac77a342
@ -69,7 +69,7 @@ impl SavedBlock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// When the block was received, this node was still syncing
|
/// When the block was received, this node was still syncing
|
||||||
pub fn was_syncing(&self) -> bool {
|
pub fn syncing(&self) -> bool {
|
||||||
// TODO: margin should come from a global config
|
// TODO: margin should come from a global config
|
||||||
self.lag > 60
|
self.lag > 60
|
||||||
}
|
}
|
||||||
@ -85,7 +85,7 @@ impl Display for SavedBlock {
|
|||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
write!(f, "{} ({})", self.number(), self.hash())?;
|
write!(f, "{} ({})", self.number(), self.hash())?;
|
||||||
|
|
||||||
if self.was_syncing() {
|
if self.syncing() {
|
||||||
write!(f, " (behind by {} seconds)", self.lag)?;
|
write!(f, " (behind by {} seconds)", self.lag)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -307,7 +307,7 @@ impl Web3Connections {
|
|||||||
// we don't know if its on the heaviest chain yet
|
// we don't know if its on the heaviest chain yet
|
||||||
self.save_block(&rpc_head_block.block, false).await?;
|
self.save_block(&rpc_head_block.block, false).await?;
|
||||||
|
|
||||||
if rpc_head_block.was_syncing() {
|
if rpc_head_block.syncing() {
|
||||||
if connection_heads.remove(&rpc.name).is_some() {
|
if connection_heads.remove(&rpc.name).is_some() {
|
||||||
warn!("{} is behind by {} seconds", &rpc.name, rpc_head_block.lag);
|
warn!("{} is behind by {} seconds", &rpc.name, rpc_head_block.lag);
|
||||||
};
|
};
|
||||||
@ -590,7 +590,7 @@ impl Web3Connections {
|
|||||||
}
|
}
|
||||||
Ordering::Greater => {
|
Ordering::Greater => {
|
||||||
debug!(
|
debug!(
|
||||||
"new {}/{}/{} con head={} rpc_head={} rpc={}",
|
"new {}/{}/{} con_head={} rpc_head={} rpc={}",
|
||||||
num_consensus_rpcs,
|
num_consensus_rpcs,
|
||||||
num_connection_heads,
|
num_connection_heads,
|
||||||
total_conns,
|
total_conns,
|
||||||
|
@ -277,7 +277,15 @@ impl Web3Connection {
|
|||||||
pub fn has_block_data(&self, needed_block_num: &U64) -> bool {
|
pub fn has_block_data(&self, needed_block_num: &U64) -> bool {
|
||||||
let head_block_num = match self.head_block.read().clone() {
|
let head_block_num = match self.head_block.read().clone() {
|
||||||
None => return false,
|
None => return false,
|
||||||
Some(x) => x.number(),
|
Some(x) => {
|
||||||
|
if x.syncing() {
|
||||||
|
// skip syncing nodes. even though they might be able to serve a query,
|
||||||
|
// latency will be poor and
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
x.number()
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// this rpc doesn't have that block yet. still syncing
|
// this rpc doesn't have that block yet. still syncing
|
||||||
|
Loading…
Reference in New Issue
Block a user