cosmos-sdk/x/slashing/keeper/params.go
Dev Ojha 0b01347b8a
perf: Don't deserialize params for every validator in slashing (#18959)
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
2024-01-06 07:49:46 +00:00

43 lines
1.2 KiB
Go

package keeper
import (
"context"
"time"
sdkmath "cosmossdk.io/math"
)
// SignedBlocksWindow - sliding window for downtime slashing
func (k Keeper) SignedBlocksWindow(ctx context.Context) (int64, error) {
params, err := k.Params.Get(ctx)
return params.SignedBlocksWindow, err
}
// MinSignedPerWindow - minimum blocks signed per window
func (k Keeper) MinSignedPerWindow(ctx context.Context) (int64, error) {
params, err := k.Params.Get(ctx)
if err != nil {
return 0, err
}
return params.MinSignedPerWindowInt(), nil
}
// DowntimeJailDuration - Downtime unbond duration
func (k Keeper) DowntimeJailDuration(ctx context.Context) (time.Duration, error) {
params, err := k.Params.Get(ctx)
return params.DowntimeJailDuration, err
}
// SlashFractionDoubleSign - fraction of power slashed in case of double sign
func (k Keeper) SlashFractionDoubleSign(ctx context.Context) (sdkmath.LegacyDec, error) {
params, err := k.Params.Get(ctx)
return params.SlashFractionDoubleSign, err
}
// SlashFractionDowntime - fraction of power slashed for downtime
func (k Keeper) SlashFractionDowntime(ctx context.Context) (sdkmath.LegacyDec, error) {
params, err := k.Params.Get(ctx)
return params.SlashFractionDowntime, err
}