diff --git a/CHANGELOG.md b/CHANGELOG.md index 915dec197..7bc975ce5 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 4bf29cd7d..e0746f752 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,