aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-04-29 20:49:37 +0800
committerobscuren <geffobscura@gmail.com>2015-04-29 20:49:37 +0800
commitdfbf580354711af3b542b8c6f5608852d7b90ce3 (patch)
tree95e8601b27245f543f4282a2e221ac7a16c9d592
parent735b029db95bf72c3105674c0f2b4f111e5ccdf5 (diff)
downloadgo-tangerine-dfbf580354711af3b542b8c6f5608852d7b90ce3.tar.gz
go-tangerine-dfbf580354711af3b542b8c6f5608852d7b90ce3.tar.zst
go-tangerine-dfbf580354711af3b542b8c6f5608852d7b90ce3.zip
eth/downloader: ignore orphan blocks in the downloader.
When blocks have been sorted and are being processed, orphan blocks should be ignored and thrown out. The protocol handler is responsible for downloading blocks which have missing parents.
-rw-r--r--eth/downloader/downloader.go14
1 files changed, 9 insertions, 5 deletions
diff --git a/eth/downloader/downloader.go b/eth/downloader/downloader.go
index a7e83a532..81808b4f8 100644
--- a/eth/downloader/downloader.go
+++ b/eth/downloader/downloader.go
@@ -418,14 +418,16 @@ func (d *Downloader) process(peer *peer) error {
// link). We should at least check whihc queue match. This code could move
// to a seperate goroutine where it periodically checks for linked pieces.
types.BlockBy(types.Number).Sort(d.queue.blocks)
- blocks := d.queue.blocks
- if len(blocks) == 0 {
+ if len(d.queue.blocks) == 0 {
return nil
}
+ var (
+ blocks = d.queue.blocks
+ err error
+ )
glog.V(logger.Debug).Infof("Inserting chain with %d blocks (#%v - #%v)\n", len(blocks), blocks[0].Number(), blocks[len(blocks)-1].Number())
- var err error
// Loop untill we're out of blocks
for len(blocks) != 0 {
max := int(math.Min(float64(len(blocks)), 256))
@@ -435,9 +437,11 @@ func (d *Downloader) process(peer *peer) error {
var i int
i, err = d.insertChain(blocks[:max])
if err != nil && core.IsParentErr(err) {
- glog.V(logger.Debug).Infof("Aborting process due to missing parent (%d)\n", i)
+ // Ignore the missing blocks. Handler should take care of anything that's missing.
+ glog.V(logger.Debug).Infof("Ignored block with missing parent (%d)\n", i)
+ blocks = blocks[i:]
- break
+ continue
} else if err != nil {
// immediatly unregister the false peer but do not disconnect
d.UnregisterPeer(d.activePeer)