Feat/add provingDeadlineInfoCmd live option

This commit is contained in:
beck 2022-05-25 11:12:32 +08:00
parent 2375df2b62
commit 43ec14fa9c

View File

@ -304,6 +304,14 @@ var provingDeadlineInfoCmd = &cli.Command{
Name: "deadline",
Usage: "View the current proving period deadline information by its index ",
ArgsUsage: "<deadlineIdx>",
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,6 +361,7 @@ var provingDeadlineInfoCmd = &cli.Command{
fmt.Printf("Proven Partitions: %d\n", provenPartitions)
fmt.Printf("Current: %t\n\n", di.Index == dlIdx)
if !cctx.Bool("live") {
for pIdx, partition := range partitions {
sectorCount, err := partition.AllSectors.Count()
if err != nil {
@ -380,6 +389,36 @@ var provingDeadlineInfoCmd = &cli.Command{
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
},
}