mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-12 12:51:22 +00:00
postmerge
This commit is contained in:
48
types/genesis.go
Normal file
48
types/genesis.go
Normal file
@ -0,0 +1,48 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"time"
|
||||
|
||||
. "github.com/tendermint/go-common"
|
||||
"github.com/tendermint/go-crypto"
|
||||
)
|
||||
|
||||
//------------------------------------------------------------
|
||||
// we store the gendoc in the db
|
||||
|
||||
var GenDocKey = []byte("GenDocKey")
|
||||
|
||||
//------------------------------------------------------------
|
||||
// core types for a genesis definition
|
||||
|
||||
type GenesisValidator struct {
|
||||
PubKey crypto.PubKey `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"`
|
||||
AppHash []byte `json:"app_hash"`
|
||||
}
|
||||
|
||||
// Utility method for saving GenensisDoc as JSON file.
|
||||
func (genDoc *GenesisDoc) SaveAs(file string) error {
|
||||
genDocBytes, err := json.Marshal(genDoc)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return WriteFile(file, genDocBytes, 0644)
|
||||
}
|
||||
|
||||
//------------------------------------------------------------
|
||||
// Make genesis state from file
|
||||
|
||||
func GenesisDocFromJSON(jsonBlob []byte) (*GenesisDoc, error) {
|
||||
genDoc := GenesisDoc{}
|
||||
err := json.Unmarshal(jsonBlob, &genDoc)
|
||||
return &genDoc, err
|
||||
}
|
Reference in New Issue
Block a user