BytomcliCmd.AddCommand(listKeysCmd)
BytomcliCmd.AddCommand(resetKeyPwdCmd)
- BytomcliCmd.AddCommand(isMiningCmd)
-
- BytomcliCmd.AddCommand(netInfoCmd)
- BytomcliCmd.AddCommand(netListeningCmd)
- BytomcliCmd.AddCommand(peerCountCmd)
- BytomcliCmd.AddCommand(netSyncingCmd)
-
- BytomcliCmd.AddCommand(gasRateCmd)
-
BytomcliCmd.AddCommand(createTransactionFeedCmd)
BytomcliCmd.AddCommand(listTransactionFeedsCmd)
BytomcliCmd.AddCommand(deleteTransactionFeedCmd)
BytomcliCmd.AddCommand(getTransactionFeedCmd)
BytomcliCmd.AddCommand(updateTransactionFeedCmd)
+ BytomcliCmd.AddCommand(isMiningCmd)
+ BytomcliCmd.AddCommand(setMiningCmd)
+
+ BytomcliCmd.AddCommand(netInfoCmd)
+ BytomcliCmd.AddCommand(gasRateCmd)
+
BytomcliCmd.AddCommand(versionCmd)
}
"os"
"strings"
- "github.com/bytom/util"
"github.com/spf13/cobra"
+ jww "github.com/spf13/jwalterweatherman"
+
+ "github.com/bytom/util"
)
var isMiningCmd = &cobra.Command{
},
}
-var miningCmd = &cobra.Command{
+var setMiningCmd = &cobra.Command{
Use: "set-mining <true or false>",
Short: "start or stop mining",
Args: cobra.ExactArgs(1),
default:
isMining = false
}
+
miningInfo := &struct {
IsMining bool `json:"is_mining"`
}{IsMining: isMining}
- data, exitCode := util.ClientCall("/set-mining", miningInfo)
- if exitCode != util.Success {
+
+ if _, exitCode := util.ClientCall("/set-mining", miningInfo); exitCode != util.Success {
os.Exit(exitCode)
}
- printJSON(data)
+
+ if isMining {
+ jww.FEEDBACK.Println("start mining success")
+ } else {
+ jww.FEEDBACK.Println("stop mining success")
+ }
},
}
"os"
"github.com/spf13/cobra"
- jww "github.com/spf13/jwalterweatherman"
"github.com/bytom/util"
)
printJSON(data)
},
}
-var netListeningCmd = &cobra.Command{
- Use: "net-listening",
- Short: "If client is actively listening for network connections",
- Run: func(cmd *cobra.Command, args []string) {
- data, exitCode := util.ClientCall("/net-info")
- if exitCode != util.Success {
- os.Exit(exitCode)
- }
-
- net := data.(map[string]interface{})
- jww.FEEDBACK.Printf("net listening: %v\n", net["listening"])
- },
-}
-
-var peerCountCmd = &cobra.Command{
- Use: "peer-count",
- Short: "Number of peers currently connected to the client",
- Args: cobra.NoArgs,
- Run: func(cmd *cobra.Command, args []string) {
- data, exitCode := util.ClientCall("/net-info")
- if exitCode != util.Success {
- os.Exit(exitCode)
- }
-
- net := data.(map[string]interface{})
- jww.FEEDBACK.Printf("peer count: %v\n", net["peer_count"])
- },
-}
-
-var netSyncingCmd = &cobra.Command{
- Use: "net-syncing",
- Short: "If the network is still syncing",
- Args: cobra.NoArgs,
- Run: func(cmd *cobra.Command, args []string) {
- data, exitCode := util.ClientCall("/net-info")
- if exitCode != util.Success {
- os.Exit(exitCode)
- }
-
- net := data.(map[string]interface{})
- jww.FEEDBACK.Printf("net syncing: %v\n", net["syncing"])
- },
-}