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

Commit

Permalink
handle queue import errors a bit more gracefully (#8385)
Browse files Browse the repository at this point in the history
  • Loading branch information
rphmeier authored Apr 13, 2018
1 parent bc2f558 commit 869fa6f
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions ethcore/sync/src/light_sync/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,8 @@ impl<L: AsLightClient> LightSync<L> {

// handles request dispatch, block import, state machine transitions, and timeouts.
fn maintain_sync(&self, ctx: &BasicContext) {
use ethcore::error::{BlockImportError, ImportError};

const DRAIN_AMOUNT: usize = 128;

let client = self.client.as_light_client();
Expand All @@ -453,11 +455,20 @@ impl<L: AsLightClient> LightSync<L> {
trace!(target: "sync", "Drained {} headers to import", sink.len());

for header in sink.drain(..) {
if let Err(e) = client.queue_header(header) {
debug!(target: "sync", "Found bad header ({:?}). Reset to search state.", e);
match client.queue_header(header) {
Ok(_) => {}
Err(BlockImportError::Import(ImportError::AlreadyInChain)) => {
trace!(target: "sync", "Block already in chain. Continuing.");
},
Err(BlockImportError::Import(ImportError::AlreadyQueued)) => {
trace!(target: "sync", "Block already queued. Continuing.");
},
Err(e) => {
debug!(target: "sync", "Found bad header ({:?}). Reset to search state.", e);

self.begin_search(&mut state);
break 'a;
self.begin_search(&mut state);
break 'a;
}
}
}
}
Expand Down

0 comments on commit 869fa6f

Please sign in to comment.