fix super-committee total-raw-staked bug (#2932)

pull/2934/head
Ganesha Upadhyaya 5 years ago committed by GitHub
parent 775547821c
commit 3d0f5c1f34
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 18
      consensus/quorum/one-node-staked-vote.go

@ -184,18 +184,20 @@ func (v *stakedVoteWeight) MarshalJSON() ([]byte, error) {
}
type t struct {
Policy string `json:"policy"`
Count int `json:"count"`
Externals int `json:"external-validator-slot-count"`
Participants []u `json:"committee-members"`
HmyVotingPower string `json:"hmy-voting-power"`
StakedVotingPower string `json:"staked-voting-power"`
TotalStaked string `json:"total-raw-staked"`
Policy string `json:"policy"`
Count int `json:"count"`
Externals int `json:"external-validator-slot-count"`
Participants []u `json:"committee-members"`
HmyVotingPower string `json:"hmy-voting-power"`
StakedVotingPower string `json:"staked-voting-power"`
TotalRawStake string `json:"total-raw-stake"`
TotalEffectiveStake string `json:"total-effective-stake"`
}
parts := make([]u, voterCount)
i, externalCount := 0, 0
totalRaw := numeric.ZeroDec()
for identity, voter := range v.roster.Voters {
member := u{
voter.IsHarmonyNode,
@ -210,6 +212,7 @@ func (v *stakedVoteWeight) MarshalJSON() ([]byte, error) {
externalCount++
member.EffectiveStake = voter.EffectiveStake.String()
member.RawStake = voter.RawStake.String()
totalRaw = totalRaw.Add(voter.RawStake)
}
parts[i] = member
i++
@ -222,6 +225,7 @@ func (v *stakedVoteWeight) MarshalJSON() ([]byte, error) {
parts,
v.roster.OurVotingPowerTotalPercentage.String(),
v.roster.TheirVotingPowerTotalPercentage.String(),
totalRaw.String(),
v.roster.TotalEffectiveStake.String(),
})
}

Loading…
Cancel
Save