OSDN Git Service

fix review
authormars <mars@bytom.io>
Thu, 25 Jul 2019 08:16:29 +0000 (16:16 +0800)
committermars <mars@bytom.io>
Thu, 25 Jul 2019 08:16:29 +0000 (16:16 +0800)
toolbar/vote_reward/settlementvotereward/settlementreward.go

index 01ca037..d3abcb5 100644 (file)
@@ -59,7 +59,7 @@ func (s *SettlementReward) getVoteResultFromDB(height uint64) (voteResults []*vo
 }
 
 func (s *SettlementReward) Settlement() error {
-       for height := s.startHeight + consensus.ActiveNetParams.RoundVoteBlockNums; height <= s.endHeight; height += consensus.ActiveNetParams.RoundVoteBlockNums {
+       for height := s.startHeight + consensus.ActiveNetParams.RoundVoteBlockNums; height < s.endHeight; height += consensus.ActiveNetParams.RoundVoteBlockNums {
                totalReward, err := s.getCoinbaseReward(height + 1)
                if err == errFoundReward {
                        totalReward, err = s.getStandbyNodeReward(height - consensus.ActiveNetParams.RoundVoteBlockNums)
@@ -97,19 +97,17 @@ func (s *SettlementReward) getStandbyNodeReward(height uint64) (uint64, error) {
 
        voteInfos = common.CalcStandByNodes(voteInfos)
 
-       err = errNoStandbyNode
        totalVoteNum := uint64(0)
        xpubVoteNum := uint64(0)
        for _, voteInfo := range voteInfos {
                totalVoteNum += voteInfo.VoteNum
                if s.rewardCfg.XPub == voteInfo.Vote {
                        xpubVoteNum = voteInfo.VoteNum
-                       err = nil
                }
        }
 
-       if err != nil {
-               return 0, err
+       if xpubVoteNum != 0 {
+               return 0, errNoStandbyNode
        }
 
        amount := big.NewInt(0).SetUint64(standbyNodesRewardForConsensusCycle)