/
params.go
81 lines (66 loc) · 2.54 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
71
72
73
74
75
76
77
78
79
80
81
package keeper
import (
"github.com/persistenceOne/persistence-sdk/v2/x/oracle/types"
sdk "github.com/cosmos/cosmos-sdk/types"
)
// GetVotePeriod returns the number of blocks during which voting takes place.
func (k Keeper) GetVotePeriod(ctx sdk.Context) (res uint64) {
k.paramSpace.Get(ctx, types.KeyVotePeriod, &res)
return
}
// GetVoteThreshold returns the minimum percentage of votes that must be received
// for a ballot to pass.
func (k Keeper) GetVoteThreshold(ctx sdk.Context) (res sdk.Dec) {
k.paramSpace.Get(ctx, types.KeyVoteThreshold, &res)
return
}
// SetVoteThreshold sets min combined validator power voting on a denom to accept
// it as valid.
// TODO: this is used in tests, we should refactor the way how this is handled.
func (k Keeper) SetVoteThreshold(ctx sdk.Context, threshold sdk.Dec) error {
if err := types.ValidateVoteThreshold(threshold); err != nil {
return err
}
k.paramSpace.Set(ctx, types.KeyVoteThreshold, &threshold)
return nil
}
// GetRewardDistributionWindow returns the number of vote periods during which
// seigniorage reward comes in and then is distributed.
func (k Keeper) GetRewardDistributionWindow(ctx sdk.Context) (res uint64) {
k.paramSpace.Get(ctx, types.KeyRewardDistributionWindow, &res)
return
}
// GetSlashFraction returns oracle voting penalty rate
func (k Keeper) GetSlashFraction(ctx sdk.Context) (res sdk.Dec) {
k.paramSpace.Get(ctx, types.KeySlashFraction, &res)
return
}
// GetSlashWindow returns # of vote period for oracle slashing
func (k Keeper) GetSlashWindow(ctx sdk.Context) (res uint64) {
k.paramSpace.Get(ctx, types.KeySlashWindow, &res)
return
}
// GetMinValidPerWindow returns oracle slashing threshold
func (k Keeper) GetMinValidPerWindow(ctx sdk.Context) (res sdk.Dec) {
k.paramSpace.Get(ctx, types.KeyMinValidPerWindow, &res)
return
}
// GetParams returns the total set of oracle parameters.
func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) {
k.paramSpace.GetParamSet(ctx, ¶ms)
return
}
// SetParams sets the total set of oracle parameters.
func (k Keeper) SetParams(ctx sdk.Context, params types.Params) {
k.paramSpace.SetParamSet(ctx, ¶ms)
}
// GetAcceptList returns the denom list that can be activated
func (k Keeper) GetAcceptList(ctx sdk.Context) (res types.DenomList) {
k.paramSpace.Get(ctx, types.KeyAcceptList, &res)
return
}
// SetAcceptList updates the accepted list of assets supported by the x/oracle
// module.
func (k Keeper) SetAcceptList(ctx sdk.Context, acceptList types.DenomList) {
k.paramSpace.Set(ctx, types.KeyAcceptList, acceptList)
}