make app_options -> app_state backwards compatible

This commit is contained in:
Anton Kaliaev
2018-03-26 21:51:07 +02:00
parent 43ac92b615
commit 1c82281b77
4 changed files with 15 additions and 4 deletions

View File

@@ -28,7 +28,18 @@ type GenesisDoc struct {
ConsensusParams *ConsensusParams `json:"consensus_params,omitempty"`
Validators []GenesisValidator `json:"validators"`
AppHash cmn.HexBytes `json:"app_hash"`
AppState json.RawMessage `json:"app_state,omitempty"`
_AppState json.RawMessage `json:"app_state,omitempty"`
AppOptions json.RawMessage `json:"app_options,omitempty"` // DEPRECATED
}
// AppState returns raw application state.
// TODO: replace with AppState field during next breaking release (0.17)
func (genDoc *GenesisDoc) AppState() json.RawMessage {
if len(genDoc.AppOptions) > 0 {
return genDoc.AppOptions
} else {
return genDoc._AppState
}
}
// SaveAs is a utility method for saving GenensisDoc as a JSON file.