get blockhash
This commit is contained in:
committed by
Geoff Stuart
parent
f01419dfc2
commit
4a0ffefa42
@@ -83,6 +83,7 @@ var StateCmd = &cli.Command{
|
||||
StateNtwkVersionCmd,
|
||||
StateMinerProvingDeadlineCmd,
|
||||
StateSysActorCIDsCmd,
|
||||
StateGetBlockHashCmd,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1961,3 +1962,33 @@ var StateSysActorCIDsCmd = &cli.Command{
|
||||
return tw.Flush()
|
||||
},
|
||||
}
|
||||
|
||||
var StateGetBlockHashCmd = &cli.Command{
|
||||
Name: "blockhash",
|
||||
Usage: "Get the tipset CID - eth blockhash",
|
||||
Action: func(cctx *cli.Context) error {
|
||||
if !cctx.Args().Present() {
|
||||
return ShowHelp(cctx, fmt.Errorf("must specify address to print market balance for"))
|
||||
}
|
||||
|
||||
api, closer, err := GetFullNodeAPI(cctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer closer()
|
||||
|
||||
ctx := ReqContext(cctx)
|
||||
|
||||
ts, err := LoadTipSet(ctx, cctx, api)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
blkCid, err := ts.Key().ToStorageBlock()
|
||||
if err != nil {
|
||||
return xerrors.Errorf("failed to get tipset key block: %w", err)
|
||||
}
|
||||
fmt.Printf("tipset CID: %d\n", blkCid)
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user