Skip to content

Commit

Permalink
Merge pull request #7308 from filecoin-project/feat/sectors-list-unpr…
Browse files Browse the repository at this point in the history
…oven

Add --unproven flag to the sectors list command
  • Loading branch information
magik6k authored Sep 10, 2021
2 parents 1ce7c25 + 8612d1e commit 0a04302
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 21 deletions.
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

0 comments on commit 0a04302

Please sign in to comment.