Skip to content

Commit 313cd2b

Browse files
authored
feat(cli): lotus state sectors --show-partitions + CSV (#12834)
* Add option to show partitions and deadlines. * Print output in CSV
1 parent d842b7e commit 313cd2b

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
- Refactored Ethereum API implementation into smaller, more manageable modules in a new `github.com/filecoin-project/lotus/node/impl/eth` package. ([filecoin-project/lotus#12796](https://github.com/filecoin-project/lotus/pull/12796))
1919
- Generate the cli docs directly from the code instead compiling and executing binaries' `help` output. ([filecoin-project/lotus#12717](https://github.com/filecoin-project/lotus/pull/12717))
2020
- Add `lotus-shed msg --gas-stats` to show summarised gas stats for a given message. ([filecoin-project/lotus#12817](https://github.com/filecoin-project/lotus/pull/12817))
21+
- `lotus state sectors` now outputs CSV format and supports an optional `--show-partitions` to list sector deadlines and partitions. ([filecoin-project/lotus#12834](https://github.com/filecoin-project/lotus/pull/12834))
2122

2223
# UNRELEASED v.1.32.0
2324

cli/state.go

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,12 @@ var StateSectorsCmd = &cli.Command{
240240
Name: "sectors",
241241
Usage: "Query the sector set of a miner",
242242
ArgsUsage: "[minerAddress]",
243+
Flags: []cli.Flag{
244+
&cli.BoolFlag{
245+
Name: "show-partitions",
246+
Usage: "show sector deadlines and partitions",
247+
},
248+
},
243249
Action: func(cctx *cli.Context) error {
244250
api, closer, err := GetFullNodeAPI(cctx)
245251
if err != nil {
@@ -268,8 +274,23 @@ var StateSectorsCmd = &cli.Command{
268274
return err
269275
}
270276

277+
showPartitions := cctx.Bool("show-partitions")
278+
header := "Sector Number, Sealed CID"
279+
if showPartitions {
280+
header = "Sector Number, Deadline, Partition, Sealed CID"
281+
}
282+
fmt.Println(header)
283+
271284
for _, s := range sectors {
272-
fmt.Printf("%d: %s\n", s.SectorNumber, s.SealedCID)
285+
if showPartitions {
286+
sp, err := api.StateSectorPartition(ctx, maddr, s.SectorNumber, ts.Key())
287+
if err != nil {
288+
return err
289+
}
290+
fmt.Printf("%d, %d, %d, %s\n", s.SectorNumber, sp.Deadline, sp.Partition, s.SealedCID)
291+
} else {
292+
fmt.Printf("%d, %s\n", s.SectorNumber, s.SealedCID)
293+
}
273294
}
274295

275296
return nil

documentation/en/cli-lotus.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1353,7 +1353,8 @@ USAGE:
13531353
lotus state sectors [command options] [minerAddress]
13541354
13551355
OPTIONS:
1356-
--help, -h show help
1356+
--show-partitions show sector deadlines and partitions (default: false)
1357+
--help, -h show help
13571358
```
13581359

13591360
### lotus state active-sectors

0 commit comments

Comments
 (0)