Skip to content

Commit

Permalink
Update vi.FeePoolWithdrawalHeight upon bonding
Browse files Browse the repository at this point in the history
  • Loading branch information
jaekwon committed Oct 26, 2018
1 parent c17f425 commit b97a076
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
7 changes: 2 additions & 5 deletions x/distribution/keeper/hooks.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package keeper

import (
"fmt"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/distribution/types"
)
Expand All @@ -21,7 +19,7 @@ func (k Keeper) onValidatorCreated(ctx sdk.Context, valAddr sdk.ValAddress) {
k.SetValidatorDistInfo(ctx, vdi)
}

// Withdrawal all validator rewards
// Withdraw all validator rewards
func (k Keeper) onValidatorModified(ctx sdk.Context, valAddr sdk.ValAddress) {
// This doesn't need to be run at genesis
if ctx.BlockHeight() > 0 {
Expand All @@ -35,8 +33,7 @@ func (k Keeper) onValidatorModified(ctx sdk.Context, valAddr sdk.ValAddress) {
func (k Keeper) onValidatorPowerDidChange(ctx sdk.Context, valAddr sdk.ValAddress) {
vi := k.GetValidatorDistInfo(ctx, valAddr)
if vi.FeePoolWithdrawalHeight != ctx.BlockHeight() {
fmt.Println(vi.OperatorAddr.String(), vi.FeePoolWithdrawalHeight, ctx.BlockHeight())
panic("DID NOT UPDATE")
panic("expected validator dist info FeePoolWithdrawalHeight to be updated, but was not.")
}
}

Expand Down
1 change: 1 addition & 0 deletions x/distribution/types/validator_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ func (vi ValidatorDistInfo) TakeFeePoolRewards(fp FeePool, height int64, totalBo
fp = fp.UpdateTotalValAccum(height, totalBonded)

if fp.TotalValAccum.Accum.IsZero() {
vi.FeePoolWithdrawalHeight = height
return vi, fp
}

Expand Down

0 comments on commit b97a076

Please sign in to comment.