2018-08-31 02:03:43 -07:00
|
|
|
package keeper
|
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
|
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
2018-10-06 08:32:41 -07:00
|
|
|
"github.com/cosmos/cosmos-sdk/x/params"
|
2019-01-11 12:08:01 -08:00
|
|
|
"github.com/cosmos/cosmos-sdk/x/staking/types"
|
2018-08-31 02:03:43 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
// Default parameter namespace
|
|
|
|
const (
|
2019-02-07 17:41:23 -08:00
|
|
|
DefaultParamspace = types.ModuleName
|
2018-08-31 02:03:43 -07:00
|
|
|
)
|
|
|
|
|
2019-01-11 12:08:01 -08:00
|
|
|
// ParamTable for staking module
|
2019-02-04 18:13:04 -08:00
|
|
|
func ParamKeyTable() params.KeyTable {
|
|
|
|
return params.NewKeyTable().RegisterParamSet(&types.Params{})
|
2018-10-06 08:32:41 -07:00
|
|
|
}
|
|
|
|
|
2018-08-31 02:03:43 -07:00
|
|
|
// UnbondingTime
|
|
|
|
func (k Keeper) UnbondingTime(ctx sdk.Context) (res time.Duration) {
|
2018-09-17 08:28:13 -07:00
|
|
|
k.paramstore.Get(ctx, types.KeyUnbondingTime, &res)
|
2018-08-31 02:03:43 -07:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// MaxValidators - Maximum number of validators
|
|
|
|
func (k Keeper) MaxValidators(ctx sdk.Context) (res uint16) {
|
2018-09-17 08:28:13 -07:00
|
|
|
k.paramstore.Get(ctx, types.KeyMaxValidators, &res)
|
2018-08-31 02:03:43 -07:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2019-01-24 14:44:31 -08:00
|
|
|
// MaxEntries - Maximum number of simultaneous unbonding
|
|
|
|
// delegations or redelegations (per pair/trio)
|
|
|
|
func (k Keeper) MaxEntries(ctx sdk.Context) (res uint16) {
|
|
|
|
k.paramstore.Get(ctx, types.KeyMaxEntries, &res)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2018-08-31 02:03:43 -07:00
|
|
|
// BondDenom - Bondable coin denomination
|
|
|
|
func (k Keeper) BondDenom(ctx sdk.Context) (res string) {
|
2018-09-17 08:28:13 -07:00
|
|
|
k.paramstore.Get(ctx, types.KeyBondDenom, &res)
|
2018-08-31 02:03:43 -07:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get all parameteras as types.Params
|
2019-01-24 14:44:31 -08:00
|
|
|
func (k Keeper) GetParams(ctx sdk.Context) types.Params {
|
|
|
|
return types.NewParams(
|
|
|
|
k.UnbondingTime(ctx),
|
|
|
|
k.MaxValidators(ctx),
|
|
|
|
k.MaxEntries(ctx),
|
|
|
|
k.BondDenom(ctx),
|
|
|
|
)
|
2018-08-31 02:03:43 -07:00
|
|
|
}
|
|
|
|
|
2018-10-06 09:16:11 -07:00
|
|
|
// set the params
|
2018-08-31 02:03:43 -07:00
|
|
|
func (k Keeper) SetParams(ctx sdk.Context, params types.Params) {
|
2018-10-10 13:01:30 -07:00
|
|
|
k.paramstore.SetParamSet(ctx, ¶ms)
|
2018-08-31 02:03:43 -07:00
|
|
|
}
|