浏览代码

eth/downloader: fix a potential issue against future refactors

Péter Szilágyi 8 年之前
父节点
当前提交
96c2ab22e0
共有 1 个文件被更改,包括 4 次插入0 次删除
  1. 4 0
      eth/downloader/downloader.go

+ 4 - 0
eth/downloader/downloader.go

@@ -1491,6 +1491,10 @@ func (d *Downloader) qosTuner() {
 func (d *Downloader) qosReduceConfidence() {
 	// If we have a single peer, confidence is always 1
 	peers := uint64(d.peers.Len())
+	if peers == 0 {
+		// Ensure peer connectivity races don't catch us off guard
+		return
+	}
 	if peers == 1 {
 		atomic.StoreUint64(&d.rttConfidence, 1000000)
 		return