Merge branch 'Feat/add_provingDeadline_option' of github.com:beck-8/lotus into feat/dlinfo-enchantments

This commit is contained in:
Łukasz Magiera 2022-08-02 10:06:48 +02:00
commit b3cce636cc

View File

@ -197,6 +197,14 @@ var provingInfoCmd = &cli.Command{
var provingDeadlinesCmd = &cli.Command{ var provingDeadlinesCmd = &cli.Command{
Name: "deadlines", Name: "deadlines",
Usage: "View the current proving period deadlines information", 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 { Action: func(cctx *cli.Context) error {
api, acloser, err := lcli.GetFullNodeAPI(cctx) api, acloser, err := lcli.GetFullNodeAPI(cctx)
if err != nil { if err != nil {
@ -239,14 +247,29 @@ var provingDeadlinesCmd = &cli.Command{
sectors := uint64(0) sectors := uint64(0)
faults := uint64(0) faults := uint64(0)
var PartitionSum int
for _, partition := range partitions { for _, partition := range partitions {
sc, err := partition.AllSectors.Count() if cctx.Bool("live") {
if err != nil { sc, err := partition.LiveSectors.Count()
return err if err != nil {
} return err
}
sectors += sc if sc > 0 {
PartitionSum++
}
sectors += sc
} else {
sc, err := partition.AllSectors.Count()
if err != nil {
return err
}
PartitionSum++
sectors += sc
}
fc, err := partition.FaultySectors.Count() fc, err := partition.FaultySectors.Count()
if err != nil { if err != nil {
@ -260,7 +283,7 @@ var provingDeadlinesCmd = &cli.Command{
if di.Index == uint64(dlIdx) { if di.Index == uint64(dlIdx) {
cur += "\t(current)" 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() return tw.Flush()
@ -278,6 +301,14 @@ var provingDeadlineInfoCmd = &cli.Command{
}, },
}, },
ArgsUsage: "<deadlineIdx>", 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 { Action: func(cctx *cli.Context) error {
if cctx.Args().Len() != 1 { if cctx.Args().Len() != 1 {
@ -327,15 +358,34 @@ var provingDeadlineInfoCmd = &cli.Command{
fmt.Printf("Proven Partitions: %d\n", provenPartitions) fmt.Printf("Proven Partitions: %d\n", provenPartitions)
fmt.Printf("Current: %t\n\n", di.Index == dlIdx) fmt.Printf("Current: %t\n\n", di.Index == dlIdx)
for pIdx, partition := range partitions { var sectorCount uint64
sectorCount, err := partition.AllSectors.Count() var sectorNumbers []uint64
if err != nil {
return err for pIdx, partition := range partitions {
} if !cctx.Bool("live") {
sectorCount, err = partition.AllSectors.Count()
if err != nil {
return err
}
sectorNumbers, err = partition.AllSectors.All(sectorCount)
if err != nil {
return err
}
} else {
sectorCount, err = partition.LiveSectors.Count()
if err != nil {
return err
}
if sectorCount != 0 {
sectorNumbers, err = partition.LiveSectors.All(sectorCount)
if err != nil {
return err
}
}
sectorNumbers, err := partition.AllSectors.All(sectorCount)
if err != nil {
return err
} }
faultsCount, err := partition.FaultySectors.Count() faultsCount, err := partition.FaultySectors.Count()