OSDN Git Service

modify code
authormars <mars@bytom.io>
Thu, 18 Jul 2019 11:54:35 +0000 (19:54 +0800)
committermars <mars@bytom.io>
Thu, 18 Jul 2019 11:54:35 +0000 (19:54 +0800)
cmd/reward/command/init.go
cmd/reward/command/run.go
toolbar/reward/config/config.go

index c8b9696..c748cbc 100644 (file)
@@ -2,7 +2,6 @@ package command
 
 import (
        "os"
-       "path"
 
        log "github.com/sirupsen/logrus"
        "github.com/spf13/cobra"
@@ -10,7 +9,7 @@ import (
        cfg "github.com/vapor/toolbar/reward/config"
 )
 
-var isVoterReward bool
+var isVoteReward bool
 
 var initFilesCmd = &cobra.Command{
        Use:   "init",
@@ -19,15 +18,15 @@ var initFilesCmd = &cobra.Command{
 }
 
 func init() {
-       initFilesCmd.Flags().BoolVarP(&isVoterReward, "is_voter_reward", "", false, "Is not voting user revenue distribution")
+       initFilesCmd.Flags().BoolVarP(&isVoteReward, "is_vote_reward", "", false, "Is not voting user revenue distribution")
 
        RootCmd.AddCommand(initFilesCmd)
 }
 
 func initFiles(cmd *cobra.Command, args []string) {
        //generate the reward config file
-       config := cfg.DefaultConfig(isVoterReward)
-       configFilePath := path.Join("./", "reward.json")
+       config := cfg.DefaultConfig(isVoteReward)
+       configFilePath := cfg.ConfigFile()
        if _, err := os.Stat(configFilePath); os.IsNotExist(err) {
                if err := cfg.ExportFederationFile(configFilePath, config); err != nil {
                        log.WithFields(log.Fields{"module": logModule, "config": configFilePath, "error": err}).Fatal("fail on export reward file")
index d8be3b5..d5213cd 100644 (file)
@@ -1,7 +1,6 @@
 package command
 
 import (
-       "path"
        "time"
 
        log "github.com/sirupsen/logrus"
@@ -38,7 +37,7 @@ func init() {
 
 func runReward(cmd *cobra.Command, args []string) error {
        startTime := time.Now()
-       configFilePath := path.Join("./", "reward.json")
+       configFilePath := cfg.ConfigFile()
        config := &cfg.Config{}
        if err := cfg.LoadFederationFile(configFilePath, config); err != nil {
                cmn.Exit(cmn.Fmt("Failed to load reward information:[%s]", err.Error()))
index 3c54fec..5175d58 100644 (file)
@@ -5,6 +5,7 @@ import (
        "encoding/json"
        "io/ioutil"
        "os"
+       "path"
 
        "github.com/vapor/toolbar/common"
 )
@@ -29,6 +30,10 @@ func DefaultConfig(isVoterReward bool) *Config {
 
 }
 
+func ConfigFile() string {
+       return path.Join("./", "reward.json")
+}
+
 type Chain struct {
        ChainID     string `json:"chain_id"`
        Name        string `json:"name"`