From bd6f8d56b4756ec476482297e9ba0c25f804b8bf Mon Sep 17 00:00:00 2001 From: PJ Date: Mon, 18 Dec 2023 22:25:10 +0100 Subject: [PATCH] worker: fix panic --- worker/download.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/worker/download.go b/worker/download.go index c75687346..88d554d41 100644 --- a/worker/download.go +++ b/worker/download.go @@ -930,8 +930,14 @@ func (s *slabDownload) nextRequest(ctx context.Context, resps *sectorResponses, return nil } + // select the fastest host + fastest := s.mgr.fastest(hosts) + if fastest == (types.PublicKey{}) { + return nil // can happen if downloader got stopped + } + // make the fastest host the current host - s.curr = s.mgr.fastest(hosts) + s.curr = fastest s.used[s.curr] = struct{}{} }