Sync progress and error handling fixes (#6560)
This commit is contained in:
parent
4dc7d3dc45
commit
684b142711
@ -90,6 +90,7 @@ pub struct SyncInfo {
|
||||
last_imported_old_block_number: Option<BlockNumber>,
|
||||
num_peers: usize,
|
||||
max_peers: u32,
|
||||
snapshot_sync: bool,
|
||||
}
|
||||
|
||||
pub struct Report {
|
||||
@ -152,6 +153,7 @@ impl InformantData for FullNodeInformantData {
|
||||
last_imported_old_block_number: status.last_imported_old_block_number,
|
||||
num_peers: status.num_peers,
|
||||
max_peers: status.current_max_peers(net_config.min_peers, net_config.max_peers),
|
||||
snapshot_sync: status.is_snapshot_syncing(),
|
||||
}))
|
||||
}
|
||||
_ => (is_major_importing(self.sync.as_ref().map(|s| s.status().state), queue_info.clone()), None),
|
||||
@ -196,6 +198,7 @@ impl InformantData for LightNodeInformantData {
|
||||
last_imported_old_block_number: None,
|
||||
num_peers: peer_numbers.connected,
|
||||
max_peers: peer_numbers.max as u32,
|
||||
snapshot_sync: false,
|
||||
});
|
||||
|
||||
Report {
|
||||
@ -282,7 +285,7 @@ impl<T: InformantData> Informant<T> {
|
||||
_ => (false, 0, 0),
|
||||
}
|
||||
);
|
||||
|
||||
let snapshot_sync = snapshot_sync && sync_info.as_ref().map_or(false, |s| s.snapshot_sync);
|
||||
if !importing && !snapshot_sync && elapsed < Duration::from_secs(30) {
|
||||
return;
|
||||
}
|
||||
|
@ -695,7 +695,7 @@ impl ChainSync {
|
||||
}
|
||||
} else {
|
||||
trace!(target: "sync", "{}: Fork mismatch", peer_id);
|
||||
io.disconnect_peer(peer_id);
|
||||
io.disable_peer(peer_id);
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
@ -1153,7 +1153,7 @@ impl ChainSync {
|
||||
trace!(target: "sync", "== Connected {}: {}", peer, io.peer_info(peer));
|
||||
if let Err(e) = self.send_status(io, peer) {
|
||||
debug!(target:"sync", "Error sending status request: {:?}", e);
|
||||
io.disable_peer(peer);
|
||||
io.disconnect_peer(peer);
|
||||
} else {
|
||||
self.handshaking_peers.insert(peer, time::precise_time_ns());
|
||||
}
|
||||
@ -1454,7 +1454,7 @@ impl ChainSync {
|
||||
};
|
||||
if let Err(e) = result {
|
||||
debug!(target:"sync", "Error sending request: {:?}", e);
|
||||
sync.disable_peer(peer_id);
|
||||
sync.disconnect_peer(peer_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1463,7 +1463,7 @@ impl ChainSync {
|
||||
fn send_packet(&mut self, sync: &mut SyncIo, peer_id: PeerId, packet_id: PacketId, packet: Bytes) {
|
||||
if let Err(e) = sync.send(peer_id, packet_id, packet) {
|
||||
debug!(target:"sync", "Error sending packet: {:?}", e);
|
||||
sync.disable_peer(peer_id);
|
||||
sync.disconnect_peer(peer_id);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user