From d6105c5855dcf67739a572e3bc5596c98285929d Mon Sep 17 00:00:00 2001 From: mossid Date: Wed, 19 Sep 2018 01:27:54 +0900 Subject: [PATCH] SetFromParamStruct -> SetStruct --- x/params/store/store.go | 9 ++++++++- x/slashing/genesis.go | 2 +- x/stake/keeper/params.go | 8 +------- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/x/params/store/store.go b/x/params/store/store.go index c91827a99..a595729a3 100644 --- a/x/params/store/store.go +++ b/x/params/store/store.go @@ -112,8 +112,15 @@ func (s Store) SetRaw(ctx sdk.Context, key string, param []byte) { tstore.Set(keybz, []byte{}) } +// Get to ParamStruct +func (s Store) GetStruct(ctx sdk.Context, ps ParamStruct) { + for _, pair := range ps.KeyFieldPairs() { + s.Get(ctx, pair.Key, pair.Field) + } +} + // Set from ParamStruct -func (s Store) SetFromParamStruct(ctx sdk.Context, ps ParamStruct) { +func (s Store) SetStruct(ctx sdk.Context, ps ParamStruct) { for _, pair := range ps.KeyFieldPairs() { s.Set(ctx, pair.Key, pair.Field) } diff --git a/x/slashing/genesis.go b/x/slashing/genesis.go index 2af5e4104..64b1795a2 100644 --- a/x/slashing/genesis.go +++ b/x/slashing/genesis.go @@ -24,5 +24,5 @@ func InitGenesis(ctx sdk.Context, keeper Keeper, data GenesisState, sdata types. keeper.addPubkey(ctx, validator.GetPubKey()) } - keeper.paramstore.SetFromParamStruct(ctx, &data.Params) + keeper.paramstore.SetStruct(ctx, &data.Params) } diff --git a/x/stake/keeper/params.go b/x/stake/keeper/params.go index 1a42450a8..6b5a4f162 100644 --- a/x/stake/keeper/params.go +++ b/x/stake/keeper/params.go @@ -79,11 +79,5 @@ func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { // set the params without updating validator set func (k Keeper) SetNewParams(ctx sdk.Context, params types.Params) { - k.paramstore.Set(ctx, types.KeyInflationRateChange, params.InflationRateChange) - k.paramstore.Set(ctx, types.KeyInflationMax, params.InflationMax) - k.paramstore.Set(ctx, types.KeyInflationMin, params.InflationMin) - k.paramstore.Set(ctx, types.KeyGoalBonded, params.GoalBonded) - k.paramstore.Set(ctx, types.KeyUnbondingTime, params.UnbondingTime) - k.paramstore.Set(ctx, types.KeyMaxValidators, params.MaxValidators) - k.paramstore.Set(ctx, types.KeyBondDenom, params.BondDenom) + k.paramstore.SetStruct(ctx, ¶ms) }