Browse Source

ConsensusParams ptr in GenesisDoc for json

pull/650/head
Ethan Buchman 7 years ago
parent
commit
1f0985689d
3 changed files with 5 additions and 6 deletions
  1. +1
    -1
      state/state.go
  2. +2
    -3
      types/genesis.go
  3. +2
    -2
      types/params.go

+ 1
- 1
state/state.go View File

@ -266,7 +266,7 @@ func (s *State) GetValidators() (*types.ValidatorSet, *types.ValidatorSet) {
func (s *State) Params() types.ConsensusParams {
// TODO: this should move into the State proper
// when we allow the app to change it
return s.GenesisDoc.ConsensusParams
return *s.GenesisDoc.ConsensusParams
}
//------------------------------------------------------------------------


+ 2
- 3
types/genesis.go View File

@ -26,7 +26,7 @@ type GenesisValidator struct {
type GenesisDoc struct {
GenesisTime time.Time `json:"genesis_time"`
ChainID string `json:"chain_id"`
ConsensusParams ConsensusParams `json:"consensus_params"`
ConsensusParams *ConsensusParams `json:"consensus_params,omitempty"`
Validators []GenesisValidator `json:"validators"`
AppHash data.Bytes `json:"app_hash"`
}
@ -58,8 +58,7 @@ func (genDoc *GenesisDoc) ValidateAndComplete() error {
return errors.Errorf("Genesis doc must include non-empty chain_id")
}
var emptyParams ConsensusParams
if genDoc.ConsensusParams == emptyParams {
if genDoc.ConsensusParams == nil {
genDoc.ConsensusParams = DefaultConsensusParams()
} else {
if err := genDoc.ConsensusParams.Validate(); err != nil {


+ 2
- 2
types/params.go View File

@ -35,8 +35,8 @@ type BlockGossipParams struct {
}
// DefaultConsensusParams returns a default ConsensusParams.
func DefaultConsensusParams() ConsensusParams {
return ConsensusParams{
func DefaultConsensusParams() *ConsensusParams {
return &ConsensusParams{
DefaultBlockSizeParams(),
DefaultTxSizeParams(),
DefaultBlockGossipParams(),


Loading…
Cancel
Save