diff options
author | Péter Szilágyi <peterke@gmail.com> | 2015-05-11 21:47:58 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2015-05-11 23:21:22 +0800 |
commit | d37a2559b928a8118a5eec77e2181cb6cf566be1 (patch) | |
tree | 12fa127f605e8b814d92c74dc5a543b9821a5189 /eth/downloader/downloader.go | |
parent | 70c65835f4747d991fe8d79e7138828cd97c6ac7 (diff) | |
download | go-tangerine-d37a2559b928a8118a5eec77e2181cb6cf566be1.tar go-tangerine-d37a2559b928a8118a5eec77e2181cb6cf566be1.tar.gz go-tangerine-d37a2559b928a8118a5eec77e2181cb6cf566be1.tar.bz2 go-tangerine-d37a2559b928a8118a5eec77e2181cb6cf566be1.tar.lz go-tangerine-d37a2559b928a8118a5eec77e2181cb6cf566be1.tar.xz go-tangerine-d37a2559b928a8118a5eec77e2181cb6cf566be1.tar.zst go-tangerine-d37a2559b928a8118a5eec77e2181cb6cf566be1.zip |
eth/downloader: revert to demotion, use harsher penalty
Diffstat (limited to 'eth/downloader/downloader.go')
-rw-r--r-- | eth/downloader/downloader.go | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/eth/downloader/downloader.go b/eth/downloader/downloader.go index b1e23f58f..5e9931f59 100644 --- a/eth/downloader/downloader.go +++ b/eth/downloader/downloader.go @@ -335,7 +335,7 @@ out: // Deliver the received chunk of blocks, but drop the peer if invalid if err := d.queue.Deliver(blockPack.peerId, blockPack.blocks); err != nil { glog.V(logger.Debug).Infof("Failed delivery for peer %s: %v\n", blockPack.peerId, err) - d.peers.Unregister(blockPack.peerId) + peer.Demote() break } if glog.V(logger.Debug) { @@ -358,7 +358,9 @@ out: // 1) Time for them to respond; // 2) Measure their speed; // 3) Amount and availability. - d.peers.Unregister(pid) + if peer := d.peers.Peer(pid); peer != nil { + peer.Demote() + } } // After removing bad peers make sure we actually have sufficient peer left to keep downloading if d.peers.Peers() == 0 { @@ -372,9 +374,13 @@ out: if d.queue.Throttle() { continue } - // Send a download request to all idle peers + // Send a download request to all idle peers, until throttled idlePeers := d.peers.IdlePeers() for _, peer := range idlePeers { + // Short circuit if throttling activated since above + if d.queue.Throttle() { + break + } // Get a possible chunk. If nil is returned no chunk // could be returned due to no hashes available. request := d.queue.Reserve(peer, maxBlockFetch) |