From 17adcb77c3758d5493e73d12f71eb2418662d960 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Thu, 9 Feb 2023 17:02:41 +0100 Subject: [PATCH] sp cli: correct order in parallel sectors list --- cmd/lotus-miner/sectors.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/cmd/lotus-miner/sectors.go b/cmd/lotus-miner/sectors.go index a5c88d15cab..2dad7fc0f52 100644 --- a/cmd/lotus-miner/sectors.go +++ b/cmd/lotus-miner/sectors.go @@ -418,25 +418,24 @@ var sectorsListCmd = &cli.Command{ throttle := make(chan struct{}, cctx.Int64("check-parallelism")) - resCh := make(chan result.Result[api.SectorInfo], len(list)) + slist := make([]result.Result[api.SectorInfo], len(list)) var wg sync.WaitGroup - for _, s := range list { + for i, s := range list { throttle <- struct{}{} wg.Add(1) - go func(s abi.SectorNumber) { + go func(i int, s abi.SectorNumber) { defer wg.Done() defer func() { <-throttle }() r := result.Wrap(minerApi.SectorsStatus(ctx, s, !fast)) if r.Error != nil { r.Value.SectorID = s } - resCh <- r - }(s) + slist[i] = r + }(i, s) } wg.Wait() - close(resCh) - for rsn := range resCh { + for _, rsn := range slist { if rsn.Error != nil { tw.Write(map[string]interface{}{ "ID": rsn.Value.SectorID,