-
Notifications
You must be signed in to change notification settings - Fork 206
/
genesis.go
49 lines (43 loc) · 1.71 KB
/
genesis.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 pairing
import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/lavanet/lava/x/pairing/keeper"
"github.com/lavanet/lava/x/pairing/types"
)
// InitGenesis initializes the capability module's state from a provided genesis
// state.
func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) {
// Set all the uniquePaymentStorageClientProvider
for _, elem := range genState.UniquePaymentStorageClientProviderList {
k.SetUniquePaymentStorageClientProvider(ctx, elem)
}
// Set all the providerPaymentStorage
for _, elem := range genState.ProviderPaymentStorageList {
k.SetProviderPaymentStorage(ctx, elem)
}
// Set all the epochPayments
for _, elem := range genState.EpochPaymentsList {
k.SetEpochPayments(ctx, elem)
}
// Set all the badgeUsedCu
for _, elem := range genState.BadgeUsedCuList {
k.SetBadgeUsedCu(ctx, elem)
}
k.InitBadgeTimers(ctx, genState.BadgesTS)
k.InitProviderQoS(ctx, genState.ProviderQosFS)
// this line is used by starport scaffolding # genesis/module/init
k.SetParams(ctx, genState.Params)
}
// ExportGenesis returns the capability module's exported genesis.
func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState {
genesis := types.DefaultGenesis()
genesis.Params = k.GetParams(ctx)
genesis.UniquePaymentStorageClientProviderList = k.GetAllUniquePaymentStorageClientProvider(ctx)
genesis.ProviderPaymentStorageList = k.GetAllProviderPaymentStorage(ctx)
genesis.EpochPaymentsList = k.GetAllEpochPayments(ctx)
genesis.BadgeUsedCuList = k.GetAllBadgeUsedCu(ctx)
genesis.BadgesTS = k.ExportBadgesTimers(ctx)
genesis.ProviderQosFS = k.ExportProviderQoS(ctx)
// this line is used by starport scaffolding # genesis/module/export
return genesis
}