limit chain ID to 50 symbols max
This commit is contained in:
parent
d73c5cbdb1
commit
0f7485690e
|
@ -19,9 +19,6 @@ const (
|
|||
|
||||
// MaxAminoOverheadForBlock - amino overhead to encode the block.
|
||||
MaxAminoOverheadForBlock = 4
|
||||
|
||||
// MaxChainIDLen is a maximum length of the chain ID.
|
||||
MaxChainIDLen = 50
|
||||
)
|
||||
|
||||
// Block defines the atomic unit of a Tendermint blockchain.
|
||||
|
|
|
@ -10,6 +10,11 @@ import (
|
|||
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
|
||||
|
||||
|
@ -52,10 +57,12 @@ func (genDoc *GenesisDoc) ValidatorHash() []byte {
|
|||
// ValidateAndComplete checks that all necessary fields are present
|
||||
// and fills in defaults for optional fields left empty
|
||||
func (genDoc *GenesisDoc) ValidateAndComplete() error {
|
||||
|
||||
if genDoc.ChainID == "" {
|
||||
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 {
|
||||
genDoc.ConsensusParams = DefaultConsensusParams()
|
||||
|
|
Loading…
Reference in New Issue