Add --unproven flag to the sectors list command

This commit is contained in:
Łukasz Magiera 2021-09-02 22:07:21 +02:00
parent 1ce7c250d7
commit 8612d1e824
2 changed files with 46 additions and 21 deletions

View File

@ -266,8 +266,9 @@ var sectorsListCmd = &cli.Command{
Usage: "List sectors",
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "show-removed",
Usage: "show removed sectors",
Name: "show-removed",
Usage: "show removed sectors",
Aliases: []string{"r"},
},
&cli.BoolFlag{
Name: "color",
@ -276,12 +277,14 @@ var sectorsListCmd = &cli.Command{
Aliases: []string{"c"},
},
&cli.BoolFlag{
Name: "fast",
Usage: "don't show on-chain info for better performance",
Name: "fast",
Usage: "don't show on-chain info for better performance",
Aliases: []string{"f"},
},
&cli.BoolFlag{
Name: "events",
Usage: "display number of events the sector has received",
Name: "events",
Usage: "display number of events the sector has received",
Aliases: []string{"e"},
},
&cli.BoolFlag{
Name: "seal-time",
@ -291,6 +294,11 @@ var sectorsListCmd = &cli.Command{
Name: "states",
Usage: "filter sectors by a comma-separated list of states",
},
&cli.BoolFlag{
Name: "unproven",
Usage: "only show sectors which aren't in the 'Proving' state",
Aliases: []string{"u"},
},
},
Action: func(cctx *cli.Context) error {
if cctx.IsSet("color") {
@ -314,17 +322,33 @@ var sectorsListCmd = &cli.Command{
var list []abi.SectorNumber
showRemoved := cctx.Bool("show-removed")
states := cctx.String("states")
var states []api.SectorState
if cctx.IsSet("states") && cctx.IsSet("unproven") {
return xerrors.Errorf("only one of --states or --unproven can be specified at once")
}
if cctx.IsSet("states") {
showRemoved = true
sList := strings.Split(cctx.String("states"), ",")
states = make([]api.SectorState, len(sList))
for i := range sList {
states[i] = api.SectorState(sList[i])
}
}
if cctx.Bool("unproven") {
for state := range sealing.ExistSectorStateList {
if state == sealing.Proving {
continue
}
states = append(states, api.SectorState(state))
}
}
if len(states) == 0 {
list, err = nodeApi.SectorsList(ctx)
} else {
showRemoved = true
sList := strings.Split(states, ",")
ss := make([]api.SectorState, len(sList))
for i := range sList {
ss[i] = api.SectorState(sList[i])
}
list, err = nodeApi.SectorsListInStates(ctx, ss)
list, err = nodeApi.SectorsListInStates(ctx, states)
}
if err != nil {

View File

@ -1532,13 +1532,14 @@ USAGE:
lotus-miner sectors list [command options] [arguments...]
OPTIONS:
--show-removed show removed sectors (default: false)
--color, -c use color in display output (default: depends on output being a TTY)
--fast don't show on-chain info for better performance (default: false)
--events display number of events the sector has received (default: false)
--seal-time display how long it took for the sector to be sealed (default: false)
--states value filter sectors by a comma-separated list of states
--help, -h show help (default: false)
--show-removed, -r show removed sectors (default: false)
--color, -c use color in display output (default: depends on output being a TTY)
--fast, -f don't show on-chain info for better performance (default: false)
--events, -e display number of events the sector has received (default: false)
--seal-time display how long it took for the sector to be sealed (default: false)
--states value filter sectors by a comma-separated list of states
--unproven, -u only show sectors which aren't in the 'Proving' state (default: false)
--help, -h show help (default: false)
```