Full restart on bad block
This commit is contained in:
parent
a8772ed5c1
commit
4854f6923b
@ -282,7 +282,6 @@ impl ChainSync {
|
|||||||
self.peers.clear();
|
self.peers.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[cfg_attr(feature="dev", allow(for_kv_map))] // Because it's not possible to get `values_mut()`
|
#[cfg_attr(feature="dev", allow(for_kv_map))] // Because it's not possible to get `values_mut()`
|
||||||
/// Rest sync. Clear all downloaded data but keep the queue
|
/// Rest sync. Clear all downloaded data but keep the queue
|
||||||
fn reset(&mut self) {
|
fn reset(&mut self) {
|
||||||
@ -309,6 +308,13 @@ impl ChainSync {
|
|||||||
self.state = SyncState::NotSynced;
|
self.state = SyncState::NotSynced;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Restart sync after bad block has been detected. May end up re-downloading up to QUEUE_SIZE blocks
|
||||||
|
pub fn restart_on_bad_block(&mut self, io: &mut SyncIo) {
|
||||||
|
self.restart(io);
|
||||||
|
// Do not assume that the block queue/chain still has our last_imported_block
|
||||||
|
self.last_imported_block = None;
|
||||||
|
self.last_imported_hash = None;
|
||||||
|
}
|
||||||
/// Called by peer to report status
|
/// Called by peer to report status
|
||||||
fn on_peer_status(&mut self, io: &mut SyncIo, peer_id: PeerId, r: &UntrustedRlp) -> Result<(), PacketDecodeError> {
|
fn on_peer_status(&mut self, io: &mut SyncIo, peer_id: PeerId, r: &UntrustedRlp) -> Result<(), PacketDecodeError> {
|
||||||
let peer = PeerInfo {
|
let peer = PeerInfo {
|
||||||
@ -846,7 +852,7 @@ impl ChainSync {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if restart {
|
if restart {
|
||||||
self.restart(io);
|
self.restart_on_bad_block(io);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user