8 "github.com/spf13/cobra"
9 jww "github.com/spf13/jwalterweatherman"
11 "github.com/bytom/blockchain"
14 var isMiningCmd = &cobra.Command{
16 Short: "If client is actively mining new blocks",
17 Run: func(cmd *cobra.Command, args []string) {
18 var rawResponse []byte
19 var response blockchain.Response
20 client := mustRPCClient()
21 client.Call(context.Background(), "/is-mining", nil, &rawResponse)
23 if err := json.Unmarshal(rawResponse, &response); err != nil {
24 jww.ERROR.Println(err)
28 if response.Status == blockchain.SUCCESS {
30 res, err := strconv.ParseBool(data[0])
32 jww.ERROR.Println("Fail to parse response data")
35 jww.FEEDBACK.Printf("is mining: %v\n", res)
38 jww.ERROR.Println(response.Msg)