move PartSetSize out of the config, into ConsensusParams

This commit is contained in:
Ethan Buchman
2017-09-21 14:51:29 -04:00
parent 29bfcb0a31
commit 1f3e4d2d9a
8 changed files with 77 additions and 43 deletions
-7
View File
@@ -4,8 +4,6 @@ import (
"fmt"
"path/filepath"
"time"
"github.com/tendermint/tendermint/types" // TODO: remove
)
// Config defines the top level configuration for a Tendermint node
@@ -320,10 +318,6 @@ type ConsensusConfig struct {
CreateEmptyBlocks bool `mapstructure:"create_empty_blocks"`
CreateEmptyBlocksInterval int `mapstructure:"create_empty_blocks_interval"`
// TODO: This probably shouldn't be exposed but it makes it
// easy to write tests for the wal/replay
BlockPartSize int `mapstructure:"block_part_size"`
// Reactor sleep duration parameters are in ms
PeerGossipSleepDuration int `mapstructure:"peer_gossip_sleep_duration"`
PeerQueryMaj23SleepDuration int `mapstructure:"peer_query_maj23_sleep_duration"`
@@ -386,7 +380,6 @@ func DefaultConsensusConfig() *ConsensusConfig {
MaxBlockSizeBytes: 1, // TODO
CreateEmptyBlocks: true,
CreateEmptyBlocksInterval: 0,
BlockPartSize: types.DefaultBlockPartSize, // TODO: we shouldnt be importing types
PeerGossipSleepDuration: 100,
PeerQueryMaj23SleepDuration: 2000,
}
+27
View File
@@ -0,0 +1,27 @@
package config
import (
"fmt"
)
type ConsensusParams struct {
MaxBlockSizeBytes int `json:"max_block_size_bytes"`
BlockPartSizeBytes int `json:"block_part_size_bytes"`
}
func DefaultConsensusParams() *ConsensusParams {
return &ConsensusParams{
MaxBlockSizeBytes: 22020096, // 21MB
BlockPartSizeBytes: 65536, // 64kB,
}
}
func (params *ConsensusParams) Validate() error {
if params.MaxBlockSizeBytes <= 0 {
return fmt.Errorf("MaxBlockSizeBytes must be greater than 0. Got %d", params.MaxBlockSizeBytes)
}
if params.BlockPartSizeBytes <= 0 {
return fmt.Errorf("BlockPartSizeBytes must be greater than 0. Got %d", params.BlockPartSizeBytes)
}
return nil
}