-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #416 from cosmos/feature/initgen
Initialize Genesis State
- Loading branch information
Showing
20 changed files
with
271 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package baseapp | ||
|
||
import ( | ||
"encoding/json" | ||
"io/ioutil" | ||
) | ||
|
||
// TODO: remove from here and pass the AppState | ||
// through InitChain | ||
|
||
// GenesisDoc defines the initial conditions for a tendermint blockchain, in particular its validator set. | ||
type GenesisDoc struct { | ||
AppState json.RawMessage `json:"app_state,omitempty"` | ||
} | ||
|
||
// GenesisDocFromFile reads JSON data from a file and unmarshalls it into a GenesisDoc. | ||
func GenesisDocFromFile(genDocFile string) (*GenesisDoc, error) { | ||
if genDocFile == "" { | ||
var g GenesisDoc | ||
return &g, nil | ||
} | ||
jsonBlob, err := ioutil.ReadFile(genDocFile) | ||
if err != nil { | ||
return nil, err | ||
} | ||
genDoc := GenesisDoc{} | ||
err = json.Unmarshal(jsonBlob, &genDoc) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return &genDoc, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.