forked from lesnikutsa/babylon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparams.go
36 lines (32 loc) · 919 Bytes
/
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
package keeper
import (
"context"
"cosmossdk.io/math"
"github.com/babylonchain/babylon/x/btcstaking/types"
)
// SetParams sets the x/btcstaking module parameters.
func (k Keeper) SetParams(ctx context.Context, p types.Params) error {
if err := p.Validate(); err != nil {
return err
}
store := k.storeService.OpenKVStore(ctx)
bz := k.cdc.MustMarshal(&p)
return store.Set(types.ParamsKey, bz)
}
// GetParams returns the current x/btcstaking module parameters.
func (k Keeper) GetParams(ctx context.Context) (p types.Params) {
store := k.storeService.OpenKVStore(ctx)
bz, err := store.Get(types.ParamsKey)
if err != nil {
panic(err)
}
if bz == nil {
return p
}
k.cdc.MustUnmarshal(bz, &p)
return p
}
// MinCommissionRate returns the minimal commission rate of finality providers
func (k Keeper) MinCommissionRate(ctx context.Context) math.LegacyDec {
return k.GetParams(ctx).MinCommissionRate
}