Skip to content

Commit

Permalink
Add simple WriteGenesis for stake & cool modules
Browse files Browse the repository at this point in the history
  • Loading branch information
cwgoes authored and rigelrozanski committed Apr 28, 2018
1 parent ff66629 commit f71191e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cmd/gaia/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func (app *GaiaApp) initChainer(ctx sdk.Context, req abci.RequestInitChain) abci
}

// load the initial stake information
stake.InitGenesis(ctx, app.stakeKeeper, genesisState.StakeData)
app.stakeKeeper.InitGenesis(ctx, genesisState.StakeData)

return abci.ResponseInitChain{}
}
6 changes: 6 additions & 0 deletions examples/democoin/x/cool/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,9 @@ func (k Keeper) InitGenesis(ctx sdk.Context, data Genesis) error {
k.setTrend(ctx, data.Trend)
return nil
}

// WriteGenesis - output the genesis trend
func (k Keeper) WriteGenesis(ctx sdk.Context) Genesis {
trend := k.GetTrend(ctx)
return Genesis{trend}
}
9 changes: 8 additions & 1 deletion x/stake/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,21 @@ func NewEndBlocker(k Keeper) sdk.EndBlocker {
//_____________________________________________________________________

// InitGenesis - store genesis parameters
func InitGenesis(ctx sdk.Context, k Keeper, data GenesisState) {
func (k Keeper) InitGenesis(ctx sdk.Context, data GenesisState) {
k.setPool(ctx, data.Pool)
k.setParams(ctx, data.Params)
for _, candidate := range data.Candidates {
k.setCandidate(ctx, candidate)
}
}

// WriteGenesis - output genesis parameters
func (k Keeper) WriteGenesis(ctx sdk.Context) GenesisState {
pool := k.GetPool(ctx)
params := k.GetParams(ctx)
return GenesisState{pool, params}
}

//_____________________________________________________________________

// These functions assume everything has been authenticated,
Expand Down

0 comments on commit f71191e

Please sign in to comment.