Browse Source

limit chain ID to 50 symbols max

pull/2184/head
Anton Kaliaev 6 years ago
parent
commit
0f7485690e
No known key found for this signature in database GPG Key ID: 7B6881D965918214
2 changed files with 8 additions and 4 deletions
  1. +0
    -3
      types/block.go
  2. +8
    -1
      types/genesis.go

+ 0
- 3
types/block.go View File

@ -19,9 +19,6 @@ const (
// MaxAminoOverheadForBlock - amino overhead to encode the block. // MaxAminoOverheadForBlock - amino overhead to encode the block.
MaxAminoOverheadForBlock = 4 MaxAminoOverheadForBlock = 4
// MaxChainIDLen is a maximum length of the chain ID.
MaxChainIDLen = 50
) )
// Block defines the atomic unit of a Tendermint blockchain. // Block defines the atomic unit of a Tendermint blockchain.


+ 8
- 1
types/genesis.go View File

@ -10,6 +10,11 @@ import (
cmn "github.com/tendermint/tendermint/libs/common" cmn "github.com/tendermint/tendermint/libs/common"
) )
const (
// MaxChainIDLen is a maximum length of the chain ID.
MaxChainIDLen = 50
)
//------------------------------------------------------------ //------------------------------------------------------------
// core types for a genesis definition // core types for a genesis definition
@ -52,10 +57,12 @@ func (genDoc *GenesisDoc) ValidatorHash() []byte {
// ValidateAndComplete checks that all necessary fields are present // ValidateAndComplete checks that all necessary fields are present
// and fills in defaults for optional fields left empty // and fills in defaults for optional fields left empty
func (genDoc *GenesisDoc) ValidateAndComplete() error { func (genDoc *GenesisDoc) ValidateAndComplete() error {
if genDoc.ChainID == "" { if genDoc.ChainID == "" {
return cmn.NewError("Genesis doc must include non-empty chain_id") return cmn.NewError("Genesis doc must include non-empty chain_id")
} }
if len(genDoc.ChainID) > MaxChainIDLen {
return cmn.NewError(fmt.Sprintf("chain_id in genesis doc is too long (max: %d)", MaxChainIDLen))
}
if genDoc.ConsensusParams == nil { if genDoc.ConsensusParams == nil {
genDoc.ConsensusParams = DefaultConsensusParams() genDoc.ConsensusParams = DefaultConsensusParams()


Loading…
Cancel
Save