-
Notifications
You must be signed in to change notification settings - Fork 199
/
params.go
58 lines (46 loc) · 1.5 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
package keeper
import (
"strconv"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/lavanet/lava/utils"
"github.com/lavanet/lava/x/pairing/types"
)
// GetParams get all parameters as types.Params
func (k Keeper) GetParams(ctx sdk.Context) types.Params {
return types.NewParams(
k.EpochBlocksOverlap(ctx),
k.QoSWeight(ctx),
k.RecommendedEpochNumToCollectPayment(ctx),
)
}
// SetParams set the params
func (k Keeper) SetParams(ctx sdk.Context, params types.Params) {
k.paramstore.SetParamSet(ctx, ¶ms)
}
func (k Keeper) EpochBlocksOverlap(ctx sdk.Context) uint64 {
var res uint64
k.paramstore.Get(ctx, types.KeyEpochBlocksOverlap, &res)
epochBlocks, err := k.epochStorageKeeper.EpochBlocks(ctx, uint64(ctx.BlockHeight()))
if err != nil {
utils.LavaFormatError("could not get epochBlocks", err,
utils.Attribute{Key: "block", Value: strconv.FormatInt(ctx.BlockHeight(), 10)},
)
return res
}
if epochBlocks < res {
res = epochBlocks
}
return res
}
func (k Keeper) QoSWeight(ctx sdk.Context) (res sdk.Dec) {
k.paramstore.Get(ctx, types.KeyQoSWeight, &res)
return
}
// RecommendedEpochNumToCollectPayment returns the RecommendedEpochNumToCollectPayment param
func (k Keeper) RecommendedEpochNumToCollectPayment(ctx sdk.Context) (res uint64) {
k.paramstore.Get(ctx, types.KeyRecommendedEpochNumToCollectPayment, &res)
return
}
func (k Keeper) SetRecommendedEpochNumToCollectPayment(ctx sdk.Context, val uint64) {
k.paramstore.Set(ctx, types.KeyRecommendedEpochNumToCollectPayment, val)
}