Skip to content

Commit

Permalink
Only apply validator set updates on initial genesis
Browse files Browse the repository at this point in the history
  • Loading branch information
cwgoes committed Nov 13, 2018
1 parent 10713e3 commit 3686a3f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 14 deletions.
6 changes: 2 additions & 4 deletions x/stake/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,13 @@ func InitGenesis(ctx sdk.Context, keeper Keeper, data types.GenesisState) (res [
keeper.InsertRedelegationQueue(ctx, red)
}

res = keeper.ApplyAndReturnValidatorSetUpdates(ctx)

// overwrite the pool since we exported
if data.Exported {
keeper.SetPool(ctx, data.Pool)
keeper.ClearLastValidatorPowers(ctx)
for _, lv := range data.LastValidatorPowers {
keeper.SetLastValidatorPower(ctx, lv.Address, lv.Power)
}
} else {
res = keeper.ApplyAndReturnValidatorSetUpdates(ctx)
}

return
Expand Down
10 changes: 0 additions & 10 deletions x/stake/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,16 +127,6 @@ func (k Keeper) IterateLastValidatorPowers(ctx sdk.Context, handler func(operato
}
}

// Clear last validator powers.
func (k Keeper) ClearLastValidatorPowers(ctx sdk.Context) {
store := ctx.KVStore(k.storeKey)
iter := sdk.KVStorePrefixIterator(store, LastValidatorPowerKey)
defer iter.Close()
for ; iter.Valid(); iter.Next() {
store.Delete(iter.Key())
}
}

// Delete the last validator power.
func (k Keeper) DeleteLastValidatorPower(ctx sdk.Context, operator sdk.ValAddress) {
store := ctx.KVStore(k.storeKey)
Expand Down

0 comments on commit 3686a3f

Please sign in to comment.