import (
"os"
- "path"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
cfg "github.com/vapor/toolbar/reward/config"
)
-var isVoterReward bool
+var isVoteReward bool
var initFilesCmd = &cobra.Command{
Use: "init",
}
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")
package command
import (
- "path"
"time"
log "github.com/sirupsen/logrus"
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()))
"encoding/json"
"io/ioutil"
"os"
+ "path"
"github.com/vapor/toolbar/common"
)
}
+func ConfigFile() string {
+ return path.Join("./", "reward.json")
+}
+
type Chain struct {
ChainID string `json:"chain_id"`
Name string `json:"name"`