-
Notifications
You must be signed in to change notification settings - Fork 37
/
genesis.go
34 lines (29 loc) · 890 Bytes
/
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
package keeper
import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/peggyjv/sommelier/v3/x/allocation/types"
)
// InitGenesis initialize default parameters
// and the keeper's address to pubkey map
func InitGenesis(ctx sdk.Context, k Keeper, gs types.GenesisState) {
k.setParams(ctx, gs.Params)
// Set the vote period at initialization
k.SetCommitPeriodStart(ctx, ctx.BlockHeight())
for _, cellar := range gs.Cellars {
k.SetCellar(ctx, *cellar)
}
}
// ExportGenesis writes the current store values
// to a genesis file, which can be imported again
// with InitGenesis
func ExportGenesis(ctx sdk.Context, k Keeper) types.GenesisState {
var cellars []*types.Cellar
k.IterateCellars(ctx, func(cellar types.Cellar) (stop bool) {
cellars = append(cellars, &cellar)
return false
})
return types.GenesisState{
Params: k.GetParamSet(ctx),
Cellars: cellars,
}
}