aboutsummaryrefslogtreecommitdiffstats
path: root/eth
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2015-06-03 20:43:12 +0800
committerPéter Szilágyi <peterke@gmail.com>2015-06-03 20:43:12 +0800
commit3ec159ab6be4dfcc51e339da562466eea38ce8b5 (patch)
tree6716c79309bbf2a752c2c4242bbb3eec10becd39 /eth
parentc9a546c310d82eb00e0e76a5e73d2ff7d601f8f0 (diff)
downloaddexon-3ec159ab6be4dfcc51e339da562466eea38ce8b5.tar
dexon-3ec159ab6be4dfcc51e339da562466eea38ce8b5.tar.gz
dexon-3ec159ab6be4dfcc51e339da562466eea38ce8b5.tar.bz2
dexon-3ec159ab6be4dfcc51e339da562466eea38ce8b5.tar.lz
dexon-3ec159ab6be4dfcc51e339da562466eea38ce8b5.tar.xz
dexon-3ec159ab6be4dfcc51e339da562466eea38ce8b5.tar.zst
dexon-3ec159ab6be4dfcc51e339da562466eea38ce8b5.zip
eth/downloader: demote peers if they exceed the soft limits at 1 blocks already
Diffstat (limited to 'eth')
-rw-r--r--eth/downloader/peer.go11
1 files changed, 8 insertions, 3 deletions
diff --git a/eth/downloader/peer.go b/eth/downloader/peer.go
index df54eecbd..8ef017df7 100644
--- a/eth/downloader/peer.go
+++ b/eth/downloader/peer.go
@@ -93,11 +93,16 @@ func (p *peer) SetIdle() {
// Calculate the new download bandwidth allowance
prev := atomic.LoadInt32(&p.capacity)
next := int32(math.Max(1, math.Min(MaxBlockFetch, float64(prev)*scale)))
- if scale < 1 {
- glog.V(logger.Detail).Infof("%s: reducing block allowance from %d to %d", p.id, prev, next)
- }
+
// Try to update the old value
if atomic.CompareAndSwapInt32(&p.capacity, prev, next) {
+ // If we're having problems at 1 capacity, try to find better peers
+ if next == 1 {
+ p.Demote()
+ }
+ if prev != next {
+ glog.V(logger.Detail).Infof("%s: changing block download capacity from %d to %d", p.id, prev, next)
+ }
break
}
}