Merge PR 1361: server: Use differing defaults from tendermint
When loading the config file, this now checks in the sdk if the file already exists. If not, it writes a config with different defaults. The defaults differ by having the profiler listen address set, and increasing the receive / send rates.
This commit is contained in:
parent
296ba2d56e
commit
eb097c4c5c
|
@ -22,6 +22,7 @@ FEATURES
|
|||
* Delegators delegate votes to validator by default but can override (for their stake)
|
||||
* [tools] make get_tools installs tendermint's linter, and gometalinter
|
||||
* [tools] Switch gometalinter to the stable version
|
||||
* [server] Default config now creates a profiler at port 6060, and increase p2p send/recv rates
|
||||
|
||||
FIXES
|
||||
* \#1259 - fix bug where certain tests that could have a nil pointer in defer
|
||||
|
|
|
@ -4,6 +4,7 @@ import (
|
|||
"encoding/json"
|
||||
"net"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/cobra"
|
||||
|
@ -46,7 +47,7 @@ func PersistentPreRunEFn(context *Context) func(*cobra.Command, []string) error
|
|||
if cmd.Name() == version.VersionCmd.Name() {
|
||||
return nil
|
||||
}
|
||||
config, err := tcmd.ParseConfig()
|
||||
config, err := interceptLoadConfig()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -65,6 +66,26 @@ func PersistentPreRunEFn(context *Context) func(*cobra.Command, []string) error
|
|||
}
|
||||
}
|
||||
|
||||
// If a new config is created, change some of the default tendermint settings
|
||||
func interceptLoadConfig() (conf *cfg.Config, err error) {
|
||||
tmpConf := cfg.DefaultConfig()
|
||||
viper.Unmarshal(tmpConf)
|
||||
rootDir := tmpConf.RootDir
|
||||
configFilePath := filepath.Join(rootDir, "config/config.toml")
|
||||
// Intercept only if the file doesn't already exist
|
||||
if _, err := os.Stat(configFilePath); os.IsNotExist(err) {
|
||||
// the following parse config is needed to create directories
|
||||
sdkDefaultConfig, _ := tcmd.ParseConfig()
|
||||
sdkDefaultConfig.ProfListenAddress = "prof_laddr=localhost:6060"
|
||||
sdkDefaultConfig.P2P.RecvRate = 5120000
|
||||
sdkDefaultConfig.P2P.SendRate = 5120000
|
||||
cfg.WriteConfigFile(configFilePath, sdkDefaultConfig)
|
||||
// Fall through, just so that its parsed into memory.
|
||||
}
|
||||
conf, err = tcmd.ParseConfig()
|
||||
return
|
||||
}
|
||||
|
||||
// add server commands
|
||||
func AddCommands(
|
||||
ctx *Context, cdc *wire.Codec,
|
||||
|
|
Loading…
Reference in New Issue