use int64 instead of numeric.Dec for uniform voter to count the votes

pull/1926/head
Chao Ma 5 years ago
parent 0b2f4d137b
commit f4ab52a99f
  1. 18
      consensus/quorum/one-node-one-vote.go

@ -36,14 +36,9 @@ func (v *uniformVoteWeight) IsQuorumAchieved(p Phase) bool {
// IsQuorumAchivedByMask ..
func (v *uniformVoteWeight) IsQuorumAchievedByMask(mask *bls_cosi.Mask) bool {
threshold := v.QuorumThreshold()
currentTotalPower := v.computeTotalPowerByMask(mask)
if currentTotalPower == nil {
utils.Logger().Warn().
Msgf("[IsQuorumAchievedByMask] currentTotalPower is nil")
return false
}
if (*currentTotalPower).LT(threshold) {
threshold := v.TwoThirdsSignersCount()
currentTotalPower := utils.CountOneBits(mask.Bitmap)
if currentTotalPower < threshold {
utils.Logger().Warn().
Msgf("[IsQuorumAchievedByMask] Not enough voting power: need %+v, have %+v", threshold, currentTotalPower)
return false
@ -63,13 +58,6 @@ func (v *uniformVoteWeight) IsRewardThresholdAchieved() bool {
return v.SignersCount(Commit) >= (v.ParticipantsCount() * 9 / 10)
}
// ComputeTotalPowerByMask computes the total power indicated by bitmap mask
func (v *uniformVoteWeight) computeTotalPowerByMask(mask *bls_cosi.Mask) *numeric.Dec {
counts := utils.CountOneBits(mask.Bitmap)
dec := numeric.NewDec(counts)
return &dec
}
func (v *uniformVoteWeight) SetVoters(
shard.SlotList,
) (*TallyResult, error) {

Loading…
Cancel
Save