Skip to content

Commit d516f3a

Browse files
committed
feat(cli): lotus chain head --height to print epoch number
A simpler version of what's currently possible with: lotus chain list --format '<height>' --count 1
1 parent 50f72ed commit d516f3a

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

CHANGELOG.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- 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))
88
- Add ChainSafe operated Calibration archival node to the bootstrap list ([filecoin-project/lotus#12517](https://github.com/filecoin-project/lotus/pull/12517))
99
- Fix hotloop in F3 pariticpation API ([filecoin-project/lotus#12575](https://github.com/filecoin-project/lotus/pull/12575))
10+
- `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))
1011

1112
## Bug Fixes
1213
- 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))
@@ -15,8 +16,6 @@
1516

1617
## Improvements
1718

18-
## Improvements
19-
2019
## Deps
2120

2221
# UNRELEASED Node v1.30.0

cli/chain.go

+12-2
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@ var ChainCmd = &cli.Command{
7272
var ChainHeadCmd = &cli.Command{
7373
Name: "head",
7474
Usage: "Print chain head",
75+
Flags: []cli.Flag{
76+
&cli.BoolFlag{
77+
Name: "height",
78+
Usage: "print just the epoch number of the chain head",
79+
},
80+
},
7581
Action: func(cctx *cli.Context) error {
7682
afmt := NewAppFmt(cctx.App)
7783

@@ -87,8 +93,12 @@ var ChainHeadCmd = &cli.Command{
8793
return err
8894
}
8995

90-
for _, c := range head.Cids() {
91-
afmt.Println(c)
96+
if cctx.Bool("height") {
97+
afmt.Println(head.Height())
98+
} else {
99+
for _, c := range head.Cids() {
100+
afmt.Println(c)
101+
}
92102
}
93103
return nil
94104
},

documentation/en/cli-lotus.md

+1
Original file line numberDiff line numberDiff line change
@@ -1616,6 +1616,7 @@ USAGE:
16161616
lotus chain head [command options] [arguments...]
16171617
16181618
OPTIONS:
1619+
--height print just the epoch number of the chain head (default: false)
16191620
--help, -h show help
16201621
```
16211622

0 commit comments

Comments
 (0)