Shed: Add a util to find the most recent null tipset
This commit is contained in:
parent
26ae8bb3a7
commit
89db4235ce
49
cmd/lotus-shed/chain.go
Normal file
49
cmd/lotus-shed/chain.go
Normal file
@ -0,0 +1,49 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
lcli "github.com/filecoin-project/lotus/cli"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
var chainCmd = &cli.Command{
|
||||
Name: "chain",
|
||||
Usage: "chain-related utilities",
|
||||
Subcommands: []*cli.Command{
|
||||
chainNullTsCmd,
|
||||
},
|
||||
}
|
||||
|
||||
var chainNullTsCmd = &cli.Command{
|
||||
Name: "latest-null",
|
||||
Usage: "finds the most recent null tipset",
|
||||
Action: func(cctx *cli.Context) error {
|
||||
api, closer, err := lcli.GetFullNodeAPI(cctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
defer closer()
|
||||
ctx := lcli.ReqContext(cctx)
|
||||
|
||||
ts, err := lcli.LoadTipSet(ctx, cctx, api)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for {
|
||||
pts, err := api.ChainGetTipSet(ctx, ts.Parents())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if ts.Height() != pts.Height()+1 {
|
||||
fmt.Println("null tipset at height ", ts.Height()-1)
|
||||
return nil
|
||||
}
|
||||
|
||||
ts = pts
|
||||
}
|
||||
},
|
||||
}
|
@ -62,6 +62,7 @@ func main() {
|
||||
minerMultisigsCmd,
|
||||
splitstoreCmd,
|
||||
fr32Cmd,
|
||||
chainCmd,
|
||||
}
|
||||
|
||||
app := &cli.App{
|
||||
|
Loading…
Reference in New Issue
Block a user