From 2375df2b62d710dd427d89b5658c0cf185cc6be8 Mon Sep 17 00:00:00 2001 From: beck Date: Wed, 25 May 2022 11:11:23 +0800 Subject: [PATCH] Feat/add provingDeadlinesCmd live option --- cmd/lotus-miner/proving.go | 57 ++++++++++++++++++++++++++++++-------- 1 file changed, 45 insertions(+), 12 deletions(-) diff --git a/cmd/lotus-miner/proving.go b/cmd/lotus-miner/proving.go index faae5e955..8b3bde610 100644 --- a/cmd/lotus-miner/proving.go +++ b/cmd/lotus-miner/proving.go @@ -197,6 +197,14 @@ var provingInfoCmd = &cli.Command{ var provingDeadlinesCmd = &cli.Command{ Name: "deadlines", Usage: "View the current proving period deadlines information", + Flags: []cli.Flag{ + &cli.BoolFlag{ + Name: "live", + Usage: "View live deadlines information", + Value: false, + Aliases: []string{"l"}, + }, + }, Action: func(cctx *cli.Context) error { api, acloser, err := lcli.GetFullNodeAPI(cctx) if err != nil { @@ -239,28 +247,53 @@ var provingDeadlinesCmd = &cli.Command{ sectors := uint64(0) faults := uint64(0) + var PartitionSum int + + if cctx.Bool("live") { + for _, partition := range partitions { + sc, err := partition.LiveSectors.Count() + if err != nil { + return err + } + + if sc > 0 { + PartitionSum++ + } + + sectors += sc + + fc, err := partition.FaultySectors.Count() + if err != nil { + return err + } + + faults += fc - for _, partition := range partitions { - sc, err := partition.AllSectors.Count() - if err != nil { - return err } + } else { + for _, partition := range partitions { + PartitionSum++ - sectors += sc + sc, err := partition.AllSectors.Count() + if err != nil { + return err + } - fc, err := partition.FaultySectors.Count() - if err != nil { - return err + sectors += sc + + fc, err := partition.FaultySectors.Count() + if err != nil { + return err + } + + faults += fc } - - faults += fc } - var cur string if di.Index == uint64(dlIdx) { cur += "\t(current)" } - _, _ = fmt.Fprintf(tw, "%d\t%d\t%d (%d)\t%d%s\n", dlIdx, len(partitions), sectors, faults, provenPartitions, cur) + _, _ = fmt.Fprintf(tw, "%d\t%d\t%d (%d)\t%d%s\n", dlIdx, PartitionSum, sectors, faults, provenPartitions, cur) } return tw.Flush()