From 96c2ab22e0980f1aa0767abe14f9306badd28538 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Tue, 2 May 2017 16:14:35 +0300 Subject: [PATCH] eth/downloader: fix a potential issue against future refactors --- eth/downloader/downloader.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/eth/downloader/downloader.go b/eth/downloader/downloader.go index d269957827..839969f03a 100644 --- a/eth/downloader/downloader.go +++ b/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