aboutsummaryrefslogtreecommitdiffstats
path: root/eth
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2015-06-19 00:43:47 +0800
committerPéter Szilágyi <peterke@gmail.com>2015-06-19 00:43:47 +0800
commitecd19919c5ec7118862fc88e2bfac19d4abbff53 (patch)
treefc403bc16d8940d10e01b89e9f1e3f5014c17a20 /eth
parent90d45f0397666cce42657849257a6f4f7cd2381c (diff)
downloaddexon-ecd19919c5ec7118862fc88e2bfac19d4abbff53.tar
dexon-ecd19919c5ec7118862fc88e2bfac19d4abbff53.tar.gz
dexon-ecd19919c5ec7118862fc88e2bfac19d4abbff53.tar.bz2
dexon-ecd19919c5ec7118862fc88e2bfac19d4abbff53.tar.lz
dexon-ecd19919c5ec7118862fc88e2bfac19d4abbff53.tar.xz
dexon-ecd19919c5ec7118862fc88e2bfac19d4abbff53.tar.zst
dexon-ecd19919c5ec7118862fc88e2bfac19d4abbff53.zip
eth/fetcher: allow backward uncle imports too
Diffstat (limited to 'eth')
-rw-r--r--eth/fetcher/fetcher.go5
1 files changed, 3 insertions, 2 deletions
diff --git a/eth/fetcher/fetcher.go b/eth/fetcher/fetcher.go
index d5ff5d77e..98170cf79 100644
--- a/eth/fetcher/fetcher.go
+++ b/eth/fetcher/fetcher.go
@@ -16,6 +16,7 @@ import (
const (
arriveTimeout = 500 * time.Millisecond // Time allowance before an announced block is explicitly requested
fetchTimeout = 5 * time.Second // Maximum alloted time to return an explicitly requested block
+ maxUncleDist = 7 // Maximum allowed backward distance from the chain head
maxQueueDist = 256 // Maximum allowed distance from the chain head to queue
)
@@ -202,7 +203,7 @@ func (f *Fetcher) loop() {
break
}
// Otherwise if fresh and still unknown, try and import
- if number <= height || f.getBlock(op.block.Hash()) != nil {
+ if number+maxUncleDist < height || f.getBlock(op.block.Hash()) != nil {
continue
}
f.insert(op.origin, op.block)
@@ -317,7 +318,7 @@ func (f *Fetcher) enqueue(peer string, block *types.Block) {
hash := block.Hash()
// Discard any past or too distant blocks
- if dist := int64(block.NumberU64()) - int64(f.chainHeight()); dist <= 0 || dist > maxQueueDist {
+ if dist := int64(block.NumberU64()) - int64(f.chainHeight()); dist < -maxUncleDist || dist > maxQueueDist {
glog.V(logger.Detail).Infof("Peer %s: discarded block #%d [%x], distance %d", peer, block.NumberU64(), hash.Bytes()[:4], dist)
return
}