ExportAppState exports the validator set and application state into two different files
(name string, app *SifchainApp, ctx sdk.Context)
| 193 | |
| 194 | // ExportAppState exports the validator set and application state into two different files |
| 195 | func 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 | } |
nothing calls this directly
no test coverage detected