Track import errors and restart sync

This commit is contained in:
arkpar 2016-03-29 23:29:43 +02:00
parent 2a2c24855c
commit 444c9c4375
1 changed files with 14 additions and 1 deletions

View File

@ -392,7 +392,10 @@ impl ChainSync {
self.have_common_block = true;
trace!(target: "sync", "Found common header {} ({})", number, hash);
} else {
trace!(target: "sync", "Header already in chain {} ({})", number, hash);
trace!(target: "sync", "Header already in chain {} ({}), restarting", number, hash);
self.restart(io);
self.continue_sync(io);
return Ok(());
}
},
_ => {
@ -467,6 +470,12 @@ impl ChainSync {
trace!(target: "sync", "Ignored block bodies while waiting");
return Ok(());
}
if item_count == 0 {
trace!(target: "sync", "No bodies returned, restarting");
self.restart(io);
self.continue_sync(io);
return Ok(());
}
for i in 0..item_count {
let body = try!(r.at(i));
let tx = try!(body.at(0));
@ -1350,6 +1359,10 @@ impl ChainSync {
// Propagate latests blocks
self.propagate_latest_blocks(io);
}
if !invalid.is_empty() {
trace!(target: "sync", "Bad blocks in the queue, restarting");
self.restart_on_bad_block(io);
}
// TODO [todr] propagate transactions?
}