From d37a7df8ff84d9270b2ee2201670151a7d7f0008 Mon Sep 17 00:00:00 2001 From: Paladz Date: Mon, 15 Mar 2021 10:57:54 +0800 Subject: [PATCH] update reward distribuction tool (#572) Co-authored-by: paladz --- .../vote_reward/settlementvotereward/settlementreward.go | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/toolbar/vote_reward/settlementvotereward/settlementreward.go b/toolbar/vote_reward/settlementvotereward/settlementreward.go index a778738a..1c60f8b7 100644 --- a/toolbar/vote_reward/settlementvotereward/settlementreward.go +++ b/toolbar/vote_reward/settlementvotereward/settlementreward.go @@ -21,7 +21,10 @@ var ( errNotRewardTx = errors.New("No reward transaction") ) -const standbyNodesRewardForConsensusCycle = 7610350076 // 400000000000000 / (365 * 24 * 60 / (500 * 1200 / 1000 / 60)) +const ( + standbyNodesRewardForConsensusCycle = 7610350076 // 400000000000000 / (365 * 24 * 60 / (500 * 1200 / 1000 / 60)) + standbyNodeNum = 32 +) type voteResult struct { VoteAddress string @@ -115,10 +118,8 @@ func (s *SettlementReward) getStandbyNodeReward(height uint64) (uint64, error) { } voteInfos = common.CalcStandByNodes(voteInfos) - - totalVoteNum, xpubVoteNum := uint64(0), uint64(0) + xpubVoteNum := uint64(0) for _, voteInfo := range voteInfos { - totalVoteNum += voteInfo.VoteNum if s.rewardCfg.XPub == voteInfo.Vote { xpubVoteNum = voteInfo.VoteNum } @@ -128,12 +129,10 @@ func (s *SettlementReward) getStandbyNodeReward(height uint64) (uint64, error) { return 0, errNotStandbyNode } - amount := big.NewInt(0).SetUint64(standbyNodesRewardForConsensusCycle) + amount := big.NewInt(0).SetUint64(standbyNodesRewardForConsensusCycle / standbyNodeNum) rewardRatio := big.NewInt(0).SetUint64(s.rewardCfg.RewardRatio) amount.Mul(amount, rewardRatio).Div(amount, big.NewInt(100)) - total := big.NewInt(0).SetUint64(totalVoteNum) - voteNum := big.NewInt(0).SetUint64(xpubVoteNum) - return amount.Mul(amount, voteNum).Div(amount, total).Uint64(), nil + return amount.Uint64(), nil } func (s *SettlementReward) getCoinbaseReward(height uint64) (uint64, error) { -- 2.11.0