cosmos-sdk/x/staking/keeper/params.go

65 lines
1.7 KiB
Go

package keeper
import (
"time"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/staking/types"
)
// UnbondingTime
func (k Keeper) UnbondingTime(ctx sdk.Context) (res time.Duration) {
k.paramstore.Get(ctx, types.KeyUnbondingTime, &res)
return
}
// MaxValidators - Maximum number of validators
func (k Keeper) MaxValidators(ctx sdk.Context) (res uint32) {
k.paramstore.Get(ctx, types.KeyMaxValidators, &res)
return
}
// MaxEntries - Maximum number of simultaneous unbonding
// delegations or redelegations (per pair/trio)
func (k Keeper) MaxEntries(ctx sdk.Context) (res uint32) {
k.paramstore.Get(ctx, types.KeyMaxEntries, &res)
return
}
// HistoricalEntries = number of historical info entries
// to persist in store
func (k Keeper) HistoricalEntries(ctx sdk.Context) (res uint32) {
k.paramstore.Get(ctx, types.KeyHistoricalEntries, &res)
return
}
// BondDenom - Bondable coin denomination
func (k Keeper) BondDenom(ctx sdk.Context) (res string) {
k.paramstore.Get(ctx, types.KeyBondDenom, &res)
return
}
// PowerReduction - is the amount of staking tokens required for 1 unit of consensus-engine power
// governance can update it on a running chain
func (k Keeper) PowerReduction(ctx sdk.Context) (res sdk.Int) {
k.paramstore.Get(ctx, types.KeyPowerReduction, &res)
return
}
// Get all parameteras as types.Params
func (k Keeper) GetParams(ctx sdk.Context) types.Params {
return types.NewParams(
k.UnbondingTime(ctx),
k.MaxValidators(ctx),
k.MaxEntries(ctx),
k.HistoricalEntries(ctx),
k.BondDenom(ctx),
k.PowerReduction(ctx),
)
}
// set the params
func (k Keeper) SetParams(ctx sdk.Context, params types.Params) {
k.paramstore.SetParamSet(ctx, &params)
}