aboutsummaryrefslogtreecommitdiffstats
path: root/eth/downloader/queue.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2015-05-11 19:26:20 +0800
committerobscuren <geffobscura@gmail.com>2015-05-11 23:21:22 +0800
commit70c65835f4747d991fe8d79e7138828cd97c6ac7 (patch)
tree6ba6612d7e4f8b6fe718d0c7db55b6313d045b40 /eth/downloader/queue.go
parentfe7e284709f079fb9ddee2d0d2667ba968db0558 (diff)
downloaddexon-70c65835f4747d991fe8d79e7138828cd97c6ac7.tar
dexon-70c65835f4747d991fe8d79e7138828cd97c6ac7.tar.gz
dexon-70c65835f4747d991fe8d79e7138828cd97c6ac7.tar.bz2
dexon-70c65835f4747d991fe8d79e7138828cd97c6ac7.tar.lz
dexon-70c65835f4747d991fe8d79e7138828cd97c6ac7.tar.xz
dexon-70c65835f4747d991fe8d79e7138828cd97c6ac7.tar.zst
dexon-70c65835f4747d991fe8d79e7138828cd97c6ac7.zip
eth/downloader: fix #910, thread safe peers & polishes
Diffstat (limited to 'eth/downloader/queue.go')
-rw-r--r--eth/downloader/queue.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/eth/downloader/queue.go b/eth/downloader/queue.go
index 515440bca..40749698c 100644
--- a/eth/downloader/queue.go
+++ b/eth/downloader/queue.go
@@ -1,3 +1,6 @@
+// Contains the block download scheduler to collect download tasks and schedule
+// them in an ordered, and throttled way.
+
package downloader
import (
@@ -8,6 +11,8 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
+ "github.com/ethereum/go-ethereum/logger"
+ "github.com/ethereum/go-ethereum/logger/glog"
"gopkg.in/karalabe/cookiejar.v2/collections/prque"
)
@@ -126,6 +131,10 @@ func (q *queue) Insert(hashes []common.Hash) {
for i, hash := range hashes {
index := q.hashCounter + i
+ if old, ok := q.hashPool[hash]; ok {
+ glog.V(logger.Warn).Infof("Hash %x already scheduled at index %v", hash, old)
+ continue
+ }
q.hashPool[hash] = index
q.hashQueue.Push(hash, float32(index)) // Highest gets schedules first
}