MCPcopy Create free account
hub / github.com/Sifchain/sifnode / ExportAppStateAndValidators

Method ExportAppStateAndValidators

app/export.go:19–48  ·  view source on GitHub ↗

ExportAppStateAndValidators exports the state of the application for a genesis file.

(
	forZeroHeight bool, jailAllowedAddrs []string,
)

Source from the content-addressed store, hash-verified

17// ExportAppStateAndValidators exports the state of the application for a genesis
18// file.
19func (app *SifchainApp) ExportAppStateAndValidators(
20 forZeroHeight bool, jailAllowedAddrs []string,
21) (servertypes.ExportedApp, error) {
22
23 // as if they could withdraw from the start of the next block
24 ctx := app.NewContext(true, tmproto.Header{Height: app.LastBlockHeight()})
25
26 // We export at last height + 1, because that's the height at which
27 // Tendermint will start InitChain.
28 height := app.LastBlockHeight() + 1
29 if forZeroHeight {
30 height = 0
31 app.prepForZeroHeightGenesis(ctx, jailAllowedAddrs)
32 }
33
34 genState := app.mm.ExportGenesis(ctx, app.appCodec)
35 appState, err := json.MarshalIndent(genState, "", " ")
36 if err != nil {
37 return servertypes.ExportedApp{}, err
38 }
39
40 validators, err := staking.WriteValidators(ctx, app.StakingKeeper)
41
42 return servertypes.ExportedApp{
43 AppState: appState,
44 Validators: validators,
45 Height: height,
46 ConsensusParams: app.BaseApp.GetConsensusParams(ctx),
47 }, err
48}
49
50// prepare for fresh start at zero height
51// NOTE zero height genesis is a temporary feature which will be deprecated

Callers 3

createSimappAndExportFunction · 0.95
ExportAppStateFunction · 0.80

Calls 2

ExportGenesisMethod · 0.65

Tested by 1