-
Notifications
You must be signed in to change notification settings - Fork 11
/
params.go
49 lines (41 loc) · 1.16 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
package validator
import (
"github.com/celer-network/sgn/x/validator/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/params"
)
// Default parameter namespace
const (
DefaultParamspace = types.ModuleName
)
// ParamTable for validator module
func ParamKeyTable() params.KeyTable {
return params.NewKeyTable().RegisterParamSet(&types.Params{})
}
// PullerDuration - puller duration
func (k Keeper) PullerDuration(ctx sdk.Context) (res uint) {
k.paramstore.Get(ctx, types.KeyPullerDuration, &res)
return
}
// PusherDuration - pusher duration
func (k Keeper) PusherDuration(ctx sdk.Context) (res uint) {
k.paramstore.Get(ctx, types.KeyPusherDuration, &res)
return
}
// MiningReward - mining reward
func (k Keeper) MiningReward(ctx sdk.Context) (res sdk.Int) {
k.paramstore.Get(ctx, types.KeyMiningReward, &res)
return
}
// Get all parameteras as types.Params
func (k Keeper) GetParams(ctx sdk.Context) types.Params {
return types.NewParams(
k.PullerDuration(ctx),
k.PusherDuration(ctx),
k.MiningReward(ctx),
)
}
// set the params
func (k Keeper) SetParams(ctx sdk.Context, params types.Params) {
k.paramstore.SetParamSet(ctx, ¶ms)
}