Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
Merge pull request #343 from ethcore/sync
Browse files Browse the repository at this point in the history
Fixed sync stalling on fork
  • Loading branch information
NikVolf committed Feb 4, 2016
2 parents 49c3b9c + 7744914 commit a87e63f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions sync/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,13 +322,13 @@ impl ChainSync {
//validate chain
let base_hash = self.last_imported_hash.clone().unwrap();
if self.have_common_block && number == self.current_base_block() + 1 && info.parent_hash != base_hash {
// TODO: lower peer rating
debug!(target: "sync", "Mismatched block header {} {}", number, hash);
continue;
// Part of the forked chain. Restart to find common block again
debug!(target: "sync", "Mismatched block header {} {}, restarting sync", number, hash);
self.restart(io);
return Ok(());
}
if self.headers.find_item(&(number - 1)).map_or(false, |p| p.hash != info.parent_hash) {
// mismatching parent id, delete the previous block and don't add this one
// TODO: lower peer rating
debug!(target: "sync", "Mismatched block header {} {}", number, hash);
self.remove_downloaded_blocks(number - 1);
continue;
Expand Down

0 comments on commit a87e63f

Please sign in to comment.