-
Notifications
You must be signed in to change notification settings - Fork 0
/
keeper.go
73 lines (60 loc) · 2.08 KB
/
keeper.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
package params
import (
"fmt"
"github.com/furyaxyz/fuxchain/libs/cosmos-sdk/codec"
sdk "github.com/furyaxyz/fuxchain/libs/cosmos-sdk/types"
sdkparams "github.com/furyaxyz/fuxchain/libs/cosmos-sdk/x/params"
"github.com/furyaxyz/fuxchain/libs/tendermint/libs/log"
"github.com/furyaxyz/fuxchain/x/params/types"
)
// Keeper is the struct of params keeper
type Keeper struct {
cdc *codec.Codec
sdkparams.Keeper
// the reference to the Paramstore to get and set gov specific params
paramSpace sdkparams.Subspace
// the reference to the DelegationSet and ValidatorSet to get information about validators and delegators
sk StakingKeeper
// the reference to the CoinKeeper to modify balances
ck BankKeeper
// the reference to the GovKeeper to insert waiting queue
gk GovKeeper
signals []func()
logger log.Logger
upgradeCache *types.UpgradeCache
}
// NewKeeper creates a new instance of params keeper
func NewKeeper(cdc *codec.Codec, key *sdk.KVStoreKey, tkey *sdk.TransientStoreKey, logger log.Logger) (
k Keeper) {
k = Keeper{
Keeper: sdkparams.NewKeeper(cdc, key, tkey),
signals: make([]func(), 0),
logger: logger.With("module", fmt.Sprintf("x/%s", ModuleName)),
upgradeCache: types.NewUpgreadeCache(key, logger, cdc),
}
k.cdc = cdc
k.paramSpace = k.Subspace(DefaultParamspace).WithKeyTable(types.ParamKeyTable())
return k
}
// SetStakingKeeper hooks the staking keeper into params keeper
func (keeper *Keeper) SetStakingKeeper(sk StakingKeeper) {
keeper.sk = sk
}
// SetBankKeeper hooks the bank keeper into params keeper
func (keeper *Keeper) SetBankKeeper(ck BankKeeper) {
keeper.ck = ck
}
// SetGovKeeper hooks the gov keeper into params keeper
func (keeper *Keeper) SetGovKeeper(gk GovKeeper) {
keeper.gk = gk
}
// SetParams sets the params into the store
func (keeper *Keeper) SetParams(ctx sdk.Context, params types.Params) {
keeper.paramSpace.SetParamSet(ctx, ¶ms)
}
// GetParams gets the params info from the store
func (keeper Keeper) GetParams(ctx sdk.Context) types.Params {
var params types.Params
keeper.paramSpace.GetParamSet(ctx, ¶ms)
return params
}