Skip to content

Commit

Permalink
feat(cli): lotus chain head --height to print epoch number
Browse files Browse the repository at this point in the history
A simpler version of what's currently possible with:

	lotus chain list --format '<height>' --count 1
  • Loading branch information
rvagg committed Oct 17, 2024
1 parent 50f72ed commit e91b338
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
3 changes: 1 addition & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- Reduce size of embedded genesis CAR files by removing WASM actor blocks and compressing with zstd. This reduces the `lotus` binary size by approximately 10 MiB. ([filecoin-project/lotus#12439](https://github.com/filecoin-project/lotus/pull/12439))
- Add ChainSafe operated Calibration archival node to the bootstrap list ([filecoin-project/lotus#12517](https://github.com/filecoin-project/lotus/pull/12517))
- Fix hotloop in F3 pariticpation API ([filecoin-project/lotus#12575](https://github.com/filecoin-project/lotus/pull/12575))
- `lotus chain head` now supports a `--height` flag to print just the epoch number of the current chain head ([filecoin-project/lotus#12609](https://github.com/filecoin-project/lotus/pull/12609))

## Bug Fixes
- Fix a bug in the `lotus-shed indexes backfill-events` command that may result in either duplicate events being backfilled where there are existing events (such an operation *should* be idempotent) or events erroneously having duplicate `logIndex` values when queried via ETH APIs. ([filecoin-project/lotus#12567](https://github.com/filecoin-project/lotus/pull/12567))
Expand All @@ -15,8 +16,6 @@

## Improvements

## Improvements

## Deps

# UNRELEASED Node v1.30.0
Expand Down
14 changes: 12 additions & 2 deletions cli/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ var ChainCmd = &cli.Command{
var ChainHeadCmd = &cli.Command{
Name: "head",
Usage: "Print chain head",
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "height",
Usage: "print just the epoch number of the chain head",
},
},
Action: func(cctx *cli.Context) error {
afmt := NewAppFmt(cctx.App)

Expand All @@ -87,8 +93,12 @@ var ChainHeadCmd = &cli.Command{
return err
}

for _, c := range head.Cids() {
afmt.Println(c)
if cctx.Bool("height") {
afmt.Println(head.Height())
} else {
for _, c := range head.Cids() {
afmt.Println(c)
}
}
return nil
},
Expand Down
1 change: 1 addition & 0 deletions documentation/en/cli-lotus.md
Original file line number Diff line number Diff line change
Expand Up @@ -1616,6 +1616,7 @@ USAGE:
lotus chain head [command options] [arguments...]
OPTIONS:
--height print just the epoch number of the chain head (default: false)
--help, -h show help
```

Expand Down

0 comments on commit e91b338

Please sign in to comment.