OSDN Git Service

remove redundacy bytomcli for net-info
authoroysheng <oysheng@bytom.io>
Wed, 25 Apr 2018 03:06:37 +0000 (11:06 +0800)
committeroysheng <oysheng@bytom.io>
Wed, 25 Apr 2018 03:06:37 +0000 (11:06 +0800)
modify set-mining response result

cmd/bytomcli/commands/bytomcli.go
cmd/bytomcli/commands/mining.go
cmd/bytomcli/commands/net.go

index 59116d1..b019c5c 100644 (file)
@@ -114,20 +114,17 @@ func AddCommands() {
        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)
 }
index 9b6e29c..7736dc1 100644 (file)
@@ -4,8 +4,10 @@ import (
        "os"
        "strings"
 
-       "github.com/bytom/util"
        "github.com/spf13/cobra"
+       jww "github.com/spf13/jwalterweatherman"
+
+       "github.com/bytom/util"
 )
 
 var isMiningCmd = &cobra.Command{
@@ -21,7 +23,7 @@ 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),
@@ -34,13 +36,19 @@ var miningCmd = &cobra.Command{
                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")
+               }
        },
 }
index 68967f8..971942d 100644 (file)
@@ -4,7 +4,6 @@ import (
        "os"
 
        "github.com/spf13/cobra"
-       jww "github.com/spf13/jwalterweatherman"
 
        "github.com/bytom/util"
 )
@@ -21,46 +20,3 @@ var netInfoCmd = &cobra.Command{
                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"])
-       },
-}