2015-11-01 11:34:08 -08:00
|
|
|
package types
|
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
|
|
|
|
. "github.com/tendermint/go-common"
|
|
|
|
"github.com/tendermint/go-crypto"
|
|
|
|
"github.com/tendermint/go-wire"
|
|
|
|
)
|
|
|
|
|
|
|
|
//------------------------------------------------------------
|
|
|
|
// we store the gendoc in the db
|
|
|
|
|
|
|
|
var GenDocKey = []byte("GenDocKey")
|
|
|
|
|
|
|
|
//------------------------------------------------------------
|
|
|
|
// core types for a genesis definition
|
|
|
|
|
|
|
|
type GenesisValidator struct {
|
|
|
|
PubKey crypto.PubKeyEd25519 `json:"pub_key"`
|
|
|
|
Amount int64 `json:"amount"`
|
|
|
|
Name string `json:"name"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type GenesisDoc struct {
|
|
|
|
GenesisTime time.Time `json:"genesis_time"`
|
|
|
|
ChainID string `json:"chain_id"`
|
|
|
|
Validators []GenesisValidator `json:"validators"`
|
2015-12-01 20:12:01 -08:00
|
|
|
AppHash []byte `json:"app_hash"`
|
2015-11-01 11:34:08 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------
|
|
|
|
// Make genesis state from file
|
|
|
|
|
|
|
|
func GenesisDocFromJSON(jsonBlob []byte) (genState *GenesisDoc) {
|
|
|
|
var err error
|
|
|
|
wire.ReadJSONPtr(&genState, jsonBlob, &err)
|
|
|
|
if err != nil {
|
|
|
|
Exit(Fmt("Couldn't read GenesisDoc: %v", err))
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|