6 log "github.com/sirupsen/logrus"
7 "github.com/spf13/cobra"
8 "github.com/tendermint/tmlibs/cli"
10 "github.com/bytom/vapor/consensus"
11 "github.com/bytom/vapor/toolbar/consensusreward"
12 cfg "github.com/bytom/vapor/toolbar/consensusreward/config"
15 const logModule = "consensusereward"
23 var RootCmd = &cobra.Command{
24 Use: "consensusreward",
25 Short: "distribution of reward.",
30 RootCmd.Flags().Uint64Var(&startHeight, "start_height", 0, "The starting height of the distributive income reward interval, It is a multiple of the dpos consensus cycle(1200). example: 1200")
31 RootCmd.Flags().Uint64Var(&endHeight, "end_height", 0, "The end height of the distributive income reward interval, It is a multiple of the dpos consensus cycle(1200). example: 2400")
32 RootCmd.Flags().StringVar(&configFile, "config_file", "reward.json", "config file. default: reward.json")
35 func runReward(cmd *cobra.Command, args []string) error {
36 startTime := time.Now()
37 config := &cfg.Config{}
38 if err := cfg.LoadConfigFile(configFile, config); err != nil {
39 log.WithFields(log.Fields{"module": logModule, "config": configFile, "error": err}).Fatal("Failded to load config file.")
41 if startHeight >= endHeight || startHeight%consensus.ActiveNetParams.RoundVoteBlockNums != 0 || endHeight%consensus.ActiveNetParams.RoundVoteBlockNums != 0 {
42 log.Fatal("Please check the height range, which must be multiple of the number of block rounds.")
45 s := consensusreward.NewStandbyNodeReward(config, startHeight, endHeight)
46 if err := s.Settlement(); err != nil {
47 log.WithFields(log.Fields{"module": logModule, "error": err}).Fatal("Standby node rewards failure.")
50 log.WithFields(log.Fields{
52 "duration": time.Since(startTime),
53 }).Info("Standby node reward complete")
59 cmd := cli.PrepareBaseCmd(RootCmd, "REWARD", "./")