-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
||
for _, partition := range partitions { | ||
sc, err := partition.AllSectors.Count() | ||
if err != nil { | ||
return err | ||
} | ||
if cctx.Bool("live") { | ||
for _, partition := range partitions { | ||
sc, err := partition.LiveSectors.Count() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
sectors += sc | ||
if sc > 0 { | ||
PartitionSum++ | ||
} | ||
|
||
sectors += sc | ||
|
||
fc, err := partition.FaultySectors.Count() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
faults += fc | ||
|
||
fc, err := partition.FaultySectors.Count() | ||
if err != nil { | ||
return err | ||
} | ||
} else { | ||
for _, partition := range partitions { | ||
PartitionSum++ | ||
|
||
faults += fc | ||
} | ||
sc, err := partition.AllSectors.Count() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
sectors += sc | ||
|
||
fc, err := partition.FaultySectors.Count() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
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() | ||
|
@@ -271,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 { | ||
|
@@ -320,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) | ||
} | ||
} else { | ||
for pIdx, partition := range partitions { | ||
sectorCount, err := partition.LiveSectors.Count() | ||
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) | ||
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) | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same thing here, only put the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @geoff-vball Sorry, I originally generated redundant code in order to reduce the number of judgments, and it has been corrected. |
||
} | ||
|
||
return nil | ||
}, | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is too much duplicated code. You should be able to make this work with an if/else statement that either uses
partition.LiveSectors.Count()
orpartition.AllSectors.Count()