mirror of
https://github.com/tendermint/tendermint.git
synced 2026-05-28 18:10:20 +00:00
types: add default values for the synchrony parameters
This commit is contained in:
@@ -113,7 +113,10 @@ func (genDoc *GenesisDoc) ValidateAndComplete() error {
|
||||
|
||||
if genDoc.ConsensusParams == nil {
|
||||
genDoc.ConsensusParams = DefaultConsensusParams()
|
||||
} else if err := genDoc.ConsensusParams.ValidateConsensusParams(); err != nil {
|
||||
}
|
||||
genDoc.ConsensusParams.Complete()
|
||||
|
||||
if err := genDoc.ConsensusParams.ValidateConsensusParams(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -128,11 +128,12 @@ func DefaultVersionParams() VersionParams {
|
||||
}
|
||||
|
||||
func DefaultSynchronyParams() SynchronyParams {
|
||||
// TODO(@wbanfield): Determine experimental values for these defaults
|
||||
// https://github.com/tendermint/tendermint/issues/7202
|
||||
return SynchronyParams{
|
||||
Precision: 500 * time.Millisecond,
|
||||
MessageDelay: 3 * time.Second,
|
||||
// 505ms was selected as the default to enable chains that have validators in
|
||||
// mixed leap-second handling environments.
|
||||
// For more information, see: https://github.com/tendermint/tendermint/issues/7724
|
||||
Precision: 505 * time.Millisecond,
|
||||
MessageDelay: 12 * time.Second,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,6 +146,12 @@ func (val *ValidatorParams) IsValidPubkeyType(pubkeyType string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (params *ConsensusParams) Complete() {
|
||||
if params.Synchrony.MessageDelay == 0 && params.Synchrony.Precision == 0 {
|
||||
params.Synchrony = DefaultSynchronyParams()
|
||||
}
|
||||
}
|
||||
|
||||
// Validate validates the ConsensusParams to ensure all values are within their
|
||||
// allowed limits, and returns an error if they are not.
|
||||
func (params ConsensusParams) ValidateConsensusParams() error {
|
||||
|
||||
Reference in New Issue
Block a user