diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d38243664..d521399747 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ - 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)) - 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)) - 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)) +- `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)) # UNRELEASED v.1.32.0 diff --git a/cli/state.go b/cli/state.go index 9bf42ec6b4..3f514d98be 100644 --- a/cli/state.go +++ b/cli/state.go @@ -240,6 +240,12 @@ var StateSectorsCmd = &cli.Command{ Name: "sectors", Usage: "Query the sector set of a miner", ArgsUsage: "[minerAddress]", + Flags: []cli.Flag{ + &cli.BoolFlag{ + Name: "show-partitions", + Usage: "show sector deadlines and partitions", + }, + }, Action: func(cctx *cli.Context) error { api, closer, err := GetFullNodeAPI(cctx) if err != nil { @@ -268,8 +274,23 @@ var StateSectorsCmd = &cli.Command{ return err } + showPartitions := cctx.Bool("show-partitions") + header := "Sector Number, Sealed CID" + if showPartitions { + header = "Sector Number, Deadline, Partition, Sealed CID" + } + fmt.Println(header) + for _, s := range sectors { - fmt.Printf("%d: %s\n", s.SectorNumber, s.SealedCID) + if showPartitions { + sp, err := api.StateSectorPartition(ctx, maddr, abi.SectorNumber(s.SectorNumber), ts.Key()) + if err != nil { + return err + } + fmt.Printf("%d, %d, %d, %s\n", s.SectorNumber, sp.Deadline, sp.Partition, s.SealedCID) + } else { + fmt.Printf("%d, %s\n", s.SectorNumber, s.SealedCID) + } } return nil