Golang implemented sidechain for Bytom
Revision | 7f73f925078115b7135bad14aaf03bf4260bbdfd (tree) |
---|---|
Zeit | 2021-03-15 11:42:14 |
Autor | paladz <colt@Colt...> |
Commiter | paladz |
update reward distribuction tool
@@ -21,7 +21,10 @@ var ( | ||
21 | 21 | errNotRewardTx = errors.New("No reward transaction") |
22 | 22 | ) |
23 | 23 | |
24 | -const standbyNodesRewardForConsensusCycle = 7610350076 // 400000000000000 / (365 * 24 * 60 / (500 * 1200 / 1000 / 60)) | |
24 | +const ( | |
25 | + standbyNodesRewardForConsensusCycle = 7610350076 // 400000000000000 / (365 * 24 * 60 / (500 * 1200 / 1000 / 60)) | |
26 | + standbyNodeNum = 32 | |
27 | +) | |
25 | 28 | |
26 | 29 | type voteResult struct { |
27 | 30 | VoteAddress string |
@@ -115,10 +118,8 @@ func (s *SettlementReward) getStandbyNodeReward(height uint64) (uint64, error) { | ||
115 | 118 | } |
116 | 119 | |
117 | 120 | voteInfos = common.CalcStandByNodes(voteInfos) |
118 | - | |
119 | - totalVoteNum, xpubVoteNum := uint64(0), uint64(0) | |
121 | + xpubVoteNum := uint64(0) | |
120 | 122 | for _, voteInfo := range voteInfos { |
121 | - totalVoteNum += voteInfo.VoteNum | |
122 | 123 | if s.rewardCfg.XPub == voteInfo.Vote { |
123 | 124 | xpubVoteNum = voteInfo.VoteNum |
124 | 125 | } |
@@ -128,12 +129,10 @@ func (s *SettlementReward) getStandbyNodeReward(height uint64) (uint64, error) { | ||
128 | 129 | return 0, errNotStandbyNode |
129 | 130 | } |
130 | 131 | |
131 | - amount := big.NewInt(0).SetUint64(standbyNodesRewardForConsensusCycle) | |
132 | + amount := big.NewInt(0).SetUint64(standbyNodesRewardForConsensusCycle / standbyNodeNum) | |
132 | 133 | rewardRatio := big.NewInt(0).SetUint64(s.rewardCfg.RewardRatio) |
133 | 134 | amount.Mul(amount, rewardRatio).Div(amount, big.NewInt(100)) |
134 | - total := big.NewInt(0).SetUint64(totalVoteNum) | |
135 | - voteNum := big.NewInt(0).SetUint64(xpubVoteNum) | |
136 | - return amount.Mul(amount, voteNum).Div(amount, total).Uint64(), nil | |
135 | + return amount.Uint64(), nil | |
137 | 136 | } |
138 | 137 | |
139 | 138 | func (s *SettlementReward) getCoinbaseReward(height uint64) (uint64, error) { |