Skip to content

Commit

Permalink
Merge PR #3496: Gov validator power sdk.Int
Browse files Browse the repository at this point in the history
  • Loading branch information
sunnya97 authored and cwgoes committed Feb 5, 2019
1 parent af73368 commit 254c39a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions PENDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 4 additions & 4 deletions x/gov/tally.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit 254c39a

Please sign in to comment.