35 lines
509 B
Go
35 lines
509 B
Go
|
package cli
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
|
||
|
"gopkg.in/urfave/cli.v2"
|
||
|
)
|
||
|
|
||
|
var chainCmd = &cli.Command{
|
||
|
Name: "chain",
|
||
|
Usage: "Interact with filecoin blockchain",
|
||
|
Subcommands: []*cli.Command{
|
||
|
chainHeadCmd,
|
||
|
},
|
||
|
}
|
||
|
|
||
|
var chainHeadCmd = &cli.Command{
|
||
|
Name: "head",
|
||
|
Usage: "Print chain head",
|
||
|
Action: func(cctx *cli.Context) error {
|
||
|
api := getApi(cctx)
|
||
|
ctx := reqContext(cctx)
|
||
|
|
||
|
head, err := api.ChainHead(ctx)
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
for _, c := range head {
|
||
|
fmt.Println(c)
|
||
|
}
|
||
|
return nil
|
||
|
},
|
||
|
}
|