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

Add --unproven flag to the sectors list command #7308

Merged
merged 1 commit into from
Sep 10, 2021
Merged
Show file tree
Hide file tree
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
52 changes: 38 additions & 14 deletions cmd/lotus-miner/sectors.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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") {
Expand All @@ -314,17 +322,33 @@ var sectorsListCmd = &cli.Command{
var list []abi.SectorNumber

showRemoved := cctx.Bool("show-removed")
states := cctx.String("states")
if len(states) == 0 {
list, err = nodeApi.SectorsList(ctx)
} else {
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(states, ",")
ss := make([]api.SectorState, len(sList))
sList := strings.Split(cctx.String("states"), ",")
states = make([]api.SectorState, len(sList))
for i := range sList {
ss[i] = api.SectorState(sList[i])
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))
}
list, err = nodeApi.SectorsListInStates(ctx, ss)
}

if len(states) == 0 {
list, err = nodeApi.SectorsList(ctx)
} else {
list, err = nodeApi.SectorsListInStates(ctx, states)
}

if err != nil {
Expand Down
15 changes: 8 additions & 7 deletions documentation/en/cli-lotus-miner.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

```

Expand Down