Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add proving deadline option view live sectors information #8721

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 63 additions & 13 deletions cmd/lotus-miner/proving.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -239,14 +247,29 @@ var provingDeadlinesCmd = &cli.Command{

sectors := uint64(0)
faults := uint64(0)
var PartitionSum int

for _, partition := range partitions {
sc, err := partition.AllSectors.Count()
if err != nil {
return err
}
if cctx.Bool("live") {
sc, err := partition.LiveSectors.Count()
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()
if err != nil {
Expand All @@ -260,7 +283,7 @@ var provingDeadlinesCmd = &cli.Command{
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()
Expand All @@ -271,6 +294,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 {
Expand Down Expand Up @@ -320,15 +351,34 @@ var provingDeadlineInfoCmd = &cli.Command{
fmt.Printf("Proven Partitions: %d\n", provenPartitions)
fmt.Printf("Current: %t\n\n", di.Index == dlIdx)

var sectorCount uint64
var sectorNumbers []uint64

for pIdx, partition := range partitions {
sectorCount, err := partition.AllSectors.Count()
if err != nil {
return err
}
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()
Expand Down