-
Notifications
You must be signed in to change notification settings - Fork 11
/
params.go
70 lines (59 loc) · 2.03 KB
/
params.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package slash
import (
"github.com/celer-network/sgn/x/slash/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/params"
)
// Default parameter namespace
const (
DefaultParamspace = types.ModuleName
)
// ParamTable for slash module
func ParamKeyTable() params.KeyTable {
return params.NewKeyTable().RegisterParamSet(&types.Params{})
}
// SignedBlocksWindow - sliding window for downtime slashing
func (k Keeper) SignedBlocksWindow(ctx sdk.Context) (res int64) {
k.paramstore.Get(ctx, types.KeySignedBlocksWindow, &res)
return
}
// MinSignedPerWindow - minimum blocks signed per window
func (k Keeper) MinSignedPerWindow(ctx sdk.Context) (res sdk.Dec) {
k.paramstore.Get(ctx, types.KeyMinSignedPerWindow, &res)
return
}
// SlashFractionDoubleSign - fraction of power slashed in case of double sign
func (k Keeper) SlashFractionDoubleSign(ctx sdk.Context) (res sdk.Dec) {
k.paramstore.Get(ctx, types.KeySlashFractionDoubleSign, &res)
return
}
// SlashFractionDowntime - fraction of power slashed for downtime
func (k Keeper) SlashFractionDowntime(ctx sdk.Context) (res sdk.Dec) {
k.paramstore.Get(ctx, types.KeySlashFractionDowntime, &res)
return
}
// SlashFractionGuardFailure - fraction of power slashed for guard failure
func (k Keeper) SlashFractionGuardFailure(ctx sdk.Context) (res sdk.Dec) {
k.paramstore.Get(ctx, types.KeySlashFractionGuardFailure, &res)
return
}
// FallbackGuardReward - fraction of penalty for reward to the guard
func (k Keeper) FallbackGuardReward(ctx sdk.Context) (res sdk.Dec) {
k.paramstore.Get(ctx, types.KeyFallbackGuardReward, &res)
return
}
// Get all parameteras as types.Params
func (k Keeper) GetParams(ctx sdk.Context) types.Params {
return types.NewParams(
k.SignedBlocksWindow(ctx),
k.MinSignedPerWindow(ctx),
k.SlashFractionDoubleSign(ctx),
k.SlashFractionDowntime(ctx),
k.SlashFractionGuardFailure(ctx),
k.FallbackGuardReward(ctx),
)
}
// set the params
func (k Keeper) SetParams(ctx sdk.Context, params types.Params) {
k.paramstore.SetParamSet(ctx, ¶ms)
}