From eb097c4c5c7e60db5002a96d6628b677e2b90a7c Mon Sep 17 00:00:00 2001 From: Dev Ojha Date: Mon, 25 Jun 2018 09:33:07 -0700 Subject: [PATCH] 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. --- CHANGELOG.md | 1 + server/util.go | 23 ++++++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 915dec1971..7bc975ce53 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/server/util.go b/server/util.go index 4bf29cd7df..e0746f7528 100644 --- a/server/util.go +++ b/server/util.go @@ -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,