You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1.2 KiB

  1. package types
  2. import (
  3. "time"
  4. . "github.com/tendermint/go-common"
  5. "github.com/tendermint/go-crypto"
  6. "github.com/tendermint/go-wire"
  7. )
  8. //------------------------------------------------------------
  9. // we store the gendoc in the db
  10. var GenDocKey = []byte("GenDocKey")
  11. //------------------------------------------------------------
  12. // core types for a genesis definition
  13. type GenesisValidator struct {
  14. PubKey crypto.PubKey `json:"pub_key"`
  15. Amount int64 `json:"amount"`
  16. Name string `json:"name"`
  17. }
  18. type GenesisDoc struct {
  19. GenesisTime time.Time `json:"genesis_time"`
  20. ChainID string `json:"chain_id"`
  21. Validators []GenesisValidator `json:"validators"`
  22. AppHash []byte `json:"app_hash"`
  23. }
  24. // Utility method for saving GenensisDoc as JSON file.
  25. func (genDoc *GenesisDoc) SaveAs(file string) error {
  26. genDocBytes := wire.JSONBytesPretty(genDoc)
  27. return WriteFile(file, genDocBytes, 0644)
  28. }
  29. //------------------------------------------------------------
  30. // Make genesis state from file
  31. func GenesisDocFromJSON(jsonBlob []byte) (genDoc *GenesisDoc, err error) {
  32. wire.ReadJSONPtr(&genDoc, jsonBlob, &err)
  33. return
  34. }