aboutsummaryrefslogtreecommitdiffstats
path: root/eth/downloader/downloader.go
diff options
context:
space:
mode:
authorJeffrey Wilcke <jeffrey@ethereum.org>2015-07-09 22:23:50 +0800
committerJeffrey Wilcke <jeffrey@ethereum.org>2015-07-09 22:23:50 +0800
commit4c62ce831b7f4aba873fd0f78d90081d774c14a4 (patch)
tree515752817e7ca70fb15dd0478f5db3d811028ac9 /eth/downloader/downloader.go
parentb041aed660385a7ea06fdb39d676954250104485 (diff)
parent492d5454b1e1e1ce18999827a5fd98562bfdbe0e (diff)
downloadgo-tangerine-4c62ce831b7f4aba873fd0f78d90081d774c14a4.tar
go-tangerine-4c62ce831b7f4aba873fd0f78d90081d774c14a4.tar.gz
go-tangerine-4c62ce831b7f4aba873fd0f78d90081d774c14a4.tar.bz2
go-tangerine-4c62ce831b7f4aba873fd0f78d90081d774c14a4.tar.lz
go-tangerine-4c62ce831b7f4aba873fd0f78d90081d774c14a4.tar.xz
go-tangerine-4c62ce831b7f4aba873fd0f78d90081d774c14a4.tar.zst
go-tangerine-4c62ce831b7f4aba873fd0f78d90081d774c14a4.zip
Merge pull request #1451 from karalabe/handle-potential-TD-forge-attack
eth/downloader: drop peer if advertised TD but won't delvier
Diffstat (limited to 'eth/downloader/downloader.go')
-rw-r--r--eth/downloader/downloader.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/eth/downloader/downloader.go b/eth/downloader/downloader.go
index 5ce98816d..7cf83ada3 100644
--- a/eth/downloader/downloader.go
+++ b/eth/downloader/downloader.go
@@ -804,6 +804,8 @@ func (d *Downloader) fetchHashes(p *peer, from uint64) error {
}
// Start pulling hashes, until all are exhausted
getHashes(from)
+ gotHashes := false
+
for {
select {
case <-d.cancelCh:
@@ -825,8 +827,14 @@ func (d *Downloader) fetchHashes(p *peer, from uint64) error {
case d.processCh <- false:
case <-d.cancelCh:
}
+ // Error out if no hashes were retrieved at all
+ if !gotHashes {
+ return errStallingPeer
+ }
return nil
}
+ gotHashes = true
+
// Otherwise insert all the new hashes, aborting in case of junk
glog.V(logger.Detail).Infof("%v: inserting %d hashes from #%d", p, len(hashPack.hashes), from)