sp cli: correct order in parallel sectors list
This commit is contained in:
parent
81e056be1a
commit
17adcb77c3
@ -418,25 +418,24 @@ var sectorsListCmd = &cli.Command{
|
|||||||
|
|
||||||
throttle := make(chan struct{}, cctx.Int64("check-parallelism"))
|
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
|
var wg sync.WaitGroup
|
||||||
for _, s := range list {
|
for i, s := range list {
|
||||||
throttle <- struct{}{}
|
throttle <- struct{}{}
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
go func(s abi.SectorNumber) {
|
go func(i int, s abi.SectorNumber) {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
defer func() { <-throttle }()
|
defer func() { <-throttle }()
|
||||||
r := result.Wrap(minerApi.SectorsStatus(ctx, s, !fast))
|
r := result.Wrap(minerApi.SectorsStatus(ctx, s, !fast))
|
||||||
if r.Error != nil {
|
if r.Error != nil {
|
||||||
r.Value.SectorID = s
|
r.Value.SectorID = s
|
||||||
}
|
}
|
||||||
resCh <- r
|
slist[i] = r
|
||||||
}(s)
|
}(i, s)
|
||||||
}
|
}
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
close(resCh)
|
|
||||||
|
|
||||||
for rsn := range resCh {
|
for _, rsn := range slist {
|
||||||
if rsn.Error != nil {
|
if rsn.Error != nil {
|
||||||
tw.Write(map[string]interface{}{
|
tw.Write(map[string]interface{}{
|
||||||
"ID": rsn.Value.SectorID,
|
"ID": rsn.Value.SectorID,
|
||||||
|
Loading…
Reference in New Issue
Block a user