Merge PR #3496: Gov validator power sdk.Int

This commit is contained in:
Sunny Aggarwal 2019-02-04 16:31:08 -08:00 committed by Christopher Goes
parent af733684ac
commit 254c39a9e2
2 changed files with 5 additions and 4 deletions

View File

@ -15,6 +15,7 @@ BREAKING CHANGES
- `--tls` is now used to enable secure layer.
* Gaia
* [\#3457](https://github.com/cosmos/cosmos-sdk/issues/3457) Changed governance tally validatorGovInfo to use sdk.Int power instead of sdk.Dec
* SDK
* [\#3487](https://github.com/cosmos/cosmos-sdk/pull/3487) Move HTTP/REST utilities out of client/utils into a new dedicated client/rest package.

View File

@ -7,7 +7,7 @@ import (
// validatorGovInfo used for tallying
type validatorGovInfo struct {
Address sdk.ValAddress // address of the validator operator
Power sdk.Dec // Power of a Validator
Power sdk.Int // Power of a Validator
DelegatorShares sdk.Dec // Total outstanding delegator shares
Minus sdk.Dec // Minus of validator, used to compute validator's voting power
Vote VoteOption // Vote of the validator
@ -26,7 +26,7 @@ func tally(ctx sdk.Context, keeper Keeper, proposal Proposal) (passes bool, tall
keeper.vs.IterateBondedValidatorsByPower(ctx, func(index int64, validator sdk.Validator) (stop bool) {
currValidators[validator.GetOperator().String()] = validatorGovInfo{
Address: validator.GetOperator(),
Power: sdk.NewDecFromInt(validator.GetPower()),
Power: validator.GetPower(),
DelegatorShares: validator.GetDelegatorShares(),
Minus: sdk.ZeroDec(),
Vote: OptionEmpty,
@ -57,7 +57,7 @@ func tally(ctx sdk.Context, keeper Keeper, proposal Proposal) (passes bool, tall
currValidators[valAddrStr] = val
delegatorShare := delegation.GetShares().Quo(val.DelegatorShares)
votingPower := val.Power.Mul(delegatorShare)
votingPower := delegatorShare.MulInt(val.Power)
results[vote.Option] = results[vote.Option].Add(votingPower)
totalVotingPower = totalVotingPower.Add(votingPower)
@ -78,7 +78,7 @@ func tally(ctx sdk.Context, keeper Keeper, proposal Proposal) (passes bool, tall
sharesAfterMinus := val.DelegatorShares.Sub(val.Minus)
percentAfterMinus := sharesAfterMinus.Quo(val.DelegatorShares)
votingPower := val.Power.Mul(percentAfterMinus)
votingPower := percentAfterMinus.MulInt(val.Power)
results[val.Vote] = results[val.Vote].Add(votingPower)
totalVotingPower = totalVotingPower.Add(votingPower)