github.com/Finschia/finschia-sdk@v0.48.1/x/staking/keeper/params.go (about)

     1  package keeper
     2  
     3  import (
     4  	"time"
     5  
     6  	sdk "github.com/Finschia/finschia-sdk/types"
     7  	"github.com/Finschia/finschia-sdk/x/staking/types"
     8  )
     9  
    10  // UnbondingTime
    11  func (k Keeper) UnbondingTime(ctx sdk.Context) (res time.Duration) {
    12  	k.paramstore.Get(ctx, types.KeyUnbondingTime, &res)
    13  	return
    14  }
    15  
    16  // MaxValidators - Maximum number of validators
    17  func (k Keeper) MaxValidators(ctx sdk.Context) (res uint32) {
    18  	k.paramstore.Get(ctx, types.KeyMaxValidators, &res)
    19  	return
    20  }
    21  
    22  // MaxEntries - Maximum number of simultaneous unbonding
    23  // delegations or redelegations (per pair/trio)
    24  func (k Keeper) MaxEntries(ctx sdk.Context) (res uint32) {
    25  	k.paramstore.Get(ctx, types.KeyMaxEntries, &res)
    26  	return
    27  }
    28  
    29  // HistoricalEntries = number of historical info entries
    30  // to persist in store
    31  func (k Keeper) HistoricalEntries(ctx sdk.Context) (res uint32) {
    32  	k.paramstore.Get(ctx, types.KeyHistoricalEntries, &res)
    33  	return
    34  }
    35  
    36  // BondDenom - Bondable coin denomination
    37  func (k Keeper) BondDenom(ctx sdk.Context) (res string) {
    38  	k.paramstore.Get(ctx, types.KeyBondDenom, &res)
    39  	return
    40  }
    41  
    42  // PowerReduction - is the amount of staking tokens required for 1 unit of consensus-engine power.
    43  // Currently, this returns a global variable that the app developer can tweak.
    44  // TODO: we might turn this into an on-chain param:
    45  // https://github.com/cosmos/cosmos-sdk/issues/8365
    46  func (k Keeper) PowerReduction(ctx sdk.Context) sdk.Int {
    47  	return sdk.DefaultPowerReduction
    48  }
    49  
    50  // Get all parameteras as types.Params
    51  func (k Keeper) GetParams(ctx sdk.Context) types.Params {
    52  	return types.NewParams(
    53  		k.UnbondingTime(ctx),
    54  		k.MaxValidators(ctx),
    55  		k.MaxEntries(ctx),
    56  		k.HistoricalEntries(ctx),
    57  		k.BondDenom(ctx),
    58  	)
    59  }
    60  
    61  // set the params
    62  func (k Keeper) SetParams(ctx sdk.Context, params types.Params) {
    63  	k.paramstore.SetParamSet(ctx, &params)
    64  }