github.com/Finschia/finschia-sdk@v0.48.1/x/slashing/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/slashing/types" 8 ) 9 10 // SignedBlocksWindow - sliding window for downtime slashing 11 func (k Keeper) SignedBlocksWindow(ctx sdk.Context) (res int64) { 12 k.paramspace.Get(ctx, types.KeySignedBlocksWindow, &res) 13 return 14 } 15 16 // MinSignedPerWindow - minimum blocks signed per window 17 func (k Keeper) MinSignedPerWindow(ctx sdk.Context) int64 { 18 var minSignedPerWindow sdk.Dec 19 k.paramspace.Get(ctx, types.KeyMinSignedPerWindow, &minSignedPerWindow) 20 signedBlocksWindow := k.SignedBlocksWindow(ctx) 21 22 // NOTE: RoundInt64 will never panic as minSignedPerWindow is 23 // less than 1. 24 return minSignedPerWindow.MulInt64(signedBlocksWindow).RoundInt64() 25 } 26 27 // DowntimeJailDuration - Downtime unbond duration 28 func (k Keeper) DowntimeJailDuration(ctx sdk.Context) (res time.Duration) { 29 k.paramspace.Get(ctx, types.KeyDowntimeJailDuration, &res) 30 return 31 } 32 33 // SlashFractionDoubleSign - fraction of power slashed in case of double sign 34 func (k Keeper) SlashFractionDoubleSign(ctx sdk.Context) (res sdk.Dec) { 35 k.paramspace.Get(ctx, types.KeySlashFractionDoubleSign, &res) 36 return 37 } 38 39 // SlashFractionDowntime - fraction of power slashed for downtime 40 func (k Keeper) SlashFractionDowntime(ctx sdk.Context) (res sdk.Dec) { 41 k.paramspace.Get(ctx, types.KeySlashFractionDowntime, &res) 42 return 43 } 44 45 // GetParams returns the total set of slashing parameters. 46 func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) { 47 k.paramspace.GetParamSet(ctx, ¶ms) 48 return params 49 } 50 51 // SetParams sets the slashing parameters to the param space. 52 func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { 53 k.paramspace.SetParamSet(ctx, ¶ms) 54 }