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

Commit

Permalink
Some logging and clear stalled blocks head
Browse files Browse the repository at this point in the history
  • Loading branch information
ascjones committed Sep 18, 2018
1 parent 3fe9c92 commit 757641d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ethcore/sync/src/block_sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,10 @@ impl BlockDownloader {
if !headers.is_empty() {
// TODO: validate heads better. E.g. check that there is enough distance between blocks.
trace_sync!(self, target: "sync", "Received {} subchain heads, proceeding to download", headers.len());
match self.block_set {
BlockSet::NewBlocks => (),
BlockSet::OldBlocks => trace_sync!(self, target: "sync", "ChainHead: reset_to {:?}", hashes),
}
self.blocks.reset_to(hashes);
self.state = State::Blocks;
return Ok(DownloadAction::Reset);
Expand Down
12 changes: 12 additions & 0 deletions ethcore/sync/src/blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,15 @@ impl BlockCollection {
}

trace!(target: "sync", "Drained {} blocks, new head :{:?}", drained.len(), self.head);

// reset if head stuck, not downloading any block bodies or receipts
// for now a crude heuristic that may not cover all cases
// assumes that at least some bodies will be downloaded before all headers
// 256 = subchain heads length and 128 = subchain length. This limit could be an argument.
if drained.len() == 0 && self.blocks.len() > 128 * 256 {
info!(target: "sync", "Resetting blocks. Current head {:?}, blocks length {:?}, heads {:?}", self.head, self.blocks.len(), self.heads);
}

drained
}

Expand Down Expand Up @@ -569,6 +578,9 @@ impl BlockCollection {
}
}
}
if self.need_receipts {
trace!(target: "sync", "update_heads: {:?}", new_heads);
}
self.heads = new_heads;
}
}
Expand Down

0 comments on commit 757641d

Please sign in to comment.