aboutsummaryrefslogtreecommitdiffstats
path: root/eth/downloader/queue.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-04-19 02:25:55 +0800
committerobscuren <geffobscura@gmail.com>2015-04-19 02:25:55 +0800
commit6830ddb659270b59b5a310fdc0e581b09fae5326 (patch)
tree00d2c3a01e7af66741239ba806d824f2bba9de62 /eth/downloader/queue.go
parent7c5d50f627b223a8b0217f6ca684b4c7d1d877ef (diff)
downloaddexon-6830ddb659270b59b5a310fdc0e581b09fae5326.tar
dexon-6830ddb659270b59b5a310fdc0e581b09fae5326.tar.gz
dexon-6830ddb659270b59b5a310fdc0e581b09fae5326.tar.bz2
dexon-6830ddb659270b59b5a310fdc0e581b09fae5326.tar.lz
dexon-6830ddb659270b59b5a310fdc0e581b09fae5326.tar.xz
dexon-6830ddb659270b59b5a310fdc0e581b09fae5326.tar.zst
dexon-6830ddb659270b59b5a310fdc0e581b09fae5326.zip
downloader: free up peers from work when the downloader resets
Diffstat (limited to 'eth/downloader/queue.go')
-rw-r--r--eth/downloader/queue.go13
1 files changed, 9 insertions, 4 deletions
diff --git a/eth/downloader/queue.go b/eth/downloader/queue.go
index 5745bf1f8..ce3aa9850 100644
--- a/eth/downloader/queue.go
+++ b/eth/downloader/queue.go
@@ -60,13 +60,18 @@ func (c *queue) get(p *peer, max int) *chunk {
return false
}
- hashes.Add(v)
- i++
+ // Skip any hashes that have previously been requested from the peer
+ if !p.requested.Has(v) {
+ hashes.Add(v)
+ i++
+ }
return true
})
- // remove hashes that have previously been fetched
- hashes.Separate(p.requested)
+ // if no hashes can be requested return a nil chunk
+ if hashes.Size() == 0 {
+ return nil
+ }
// remove the fetchable hashes from hash pool
c.hashPool.Separate(hashes)