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

Function ExportAppState

app/export.go:195–219  ·  view source on GitHub ↗

ExportAppState exports the validator set and application state into two different files

(name string, app *SifchainApp, ctx sdk.Context)

Source from the content-addressed store, hash-verified

193
194// ExportAppState exports the validator set and application state into two different files
195func ExportAppState(name string, app *SifchainApp, ctx sdk.Context) {
196 appState, err := app.ExportAppStateAndValidators(true, []string{})
197 if err != nil {
198 ctx.Logger().Error("failed to export app state", "error:", err)
199 return
200 }
201 appStateJSON, err := json.MarshalIndent(appState, "", " ")
202 if err != nil {
203 ctx.Logger().Error("failed to marshal application genesis state", "error:", err.Error())
204 return
205 }
206 valList, err := json.MarshalIndent(appState.Validators, "", " ")
207 if err != nil {
208 ctx.Logger().Error("failed to marshal application genesis state", "error:", err.Error())
209 }
210
211 err = ioutil.WriteFile(fmt.Sprintf("%v/%v-state.json", DefaultNodeHome, name), appStateJSON, 0600)
212 if err != nil {
213 ctx.Logger().Error("failed to write state to file", "err", err.Error())
214 }
215 err = ioutil.WriteFile(fmt.Sprintf("%v/%v-validator.json", DefaultNodeHome, name), valList, 0600)
216 if err != nil {
217 ctx.Logger().Error("failed to write Validator List to file", "err", err.Error())
218 }
219}

Callers

nothing calls this directly

Calls 3

ErrorMethod · 0.45
LoggerMethod · 0.45

Tested by

no test coverage detected