From 43ec14fa9c40d8b220e2272663572a86d7583286 Mon Sep 17 00:00:00 2001 From: beck Date: Wed, 25 May 2022 11:12:32 +0800 Subject: [PATCH] Feat/add provingDeadlineInfoCmd live option --- cmd/lotus-miner/proving.go | 83 ++++++++++++++++++++++++++++---------- 1 file changed, 61 insertions(+), 22 deletions(-) diff --git a/cmd/lotus-miner/proving.go b/cmd/lotus-miner/proving.go index 8b3bde610..51149baf6 100644 --- a/cmd/lotus-miner/proving.go +++ b/cmd/lotus-miner/proving.go @@ -304,6 +304,14 @@ var provingDeadlineInfoCmd = &cli.Command{ Name: "deadline", Usage: "View the current proving period deadline information by its index ", ArgsUsage: "", + Flags: []cli.Flag{ + &cli.BoolFlag{ + Name: "live", + Usage: "View deadline live sectors", + Value: false, + Aliases: []string{"l"}, + }, + }, Action: func(cctx *cli.Context) error { if cctx.Args().Len() != 1 { @@ -353,33 +361,64 @@ var provingDeadlineInfoCmd = &cli.Command{ fmt.Printf("Proven Partitions: %d\n", provenPartitions) fmt.Printf("Current: %t\n\n", di.Index == dlIdx) - for pIdx, partition := range partitions { - sectorCount, err := partition.AllSectors.Count() - if err != nil { - return err - } + if !cctx.Bool("live") { + for pIdx, partition := range partitions { + sectorCount, err := partition.AllSectors.Count() + if err != nil { + return err + } - sectorNumbers, err := partition.AllSectors.All(sectorCount) - if err != nil { - return err - } + sectorNumbers, err := partition.AllSectors.All(sectorCount) + if err != nil { + return err + } - faultsCount, err := partition.FaultySectors.Count() - if err != nil { - return err - } + faultsCount, err := partition.FaultySectors.Count() + if err != nil { + return err + } - fn, err := partition.FaultySectors.All(faultsCount) - if err != nil { - return err - } + fn, err := partition.FaultySectors.All(faultsCount) + if err != nil { + return err + } - fmt.Printf("Partition Index: %d\n", pIdx) - fmt.Printf("Sectors: %d\n", sectorCount) - fmt.Printf("Sector Numbers: %v\n", sectorNumbers) - fmt.Printf("Faults: %d\n", faultsCount) - fmt.Printf("Faulty Sectors: %d\n", fn) + fmt.Printf("Partition Index: %d\n", pIdx) + fmt.Printf("Sectors: %d\n", sectorCount) + fmt.Printf("Sector Numbers: %v\n", sectorNumbers) + fmt.Printf("Faults: %d\n", faultsCount) + fmt.Printf("Faulty Sectors: %d\n", fn) + } + } else { + for pIdx, partition := range partitions { + sectorCount, err := partition.LiveSectors.Count() + if err != nil { + return err + } + + sectorNumbers, err := partition.LiveSectors.All(sectorCount) + if err != nil { + return err + } + + faultsCount, err := partition.FaultySectors.Count() + if err != nil { + return err + } + + fn, err := partition.FaultySectors.All(faultsCount) + if err != nil { + return err + } + + fmt.Printf("Partition Index: %d\n", pIdx) + fmt.Printf("Sectors: %d\n", sectorCount) + fmt.Printf("Sector Numbers: %v\n", sectorNumbers) + fmt.Printf("Faults: %d\n", faultsCount) + fmt.Printf("Faulty Sectors: %d\n", fn) + } } + return nil }, }