From e93bb9a0c6706cc68beae60f569c4d9089fe7fd1 Mon Sep 17 00:00:00 2001 From: Elliot Ng Date: Fri, 18 Mar 2022 17:17:01 +0800 Subject: [PATCH] Set default server configs for min gas price and state sync snapshots Ref oursky/likecoin-chain#115 --- cmd/liked/cmd/cmd.go | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/cmd/liked/cmd/cmd.go b/cmd/liked/cmd/cmd.go index bc674688bd..1f159e465d 100644 --- a/cmd/liked/cmd/cmd.go +++ b/cmd/liked/cmd/cmd.go @@ -45,6 +45,8 @@ import ( simappcli "github.com/cosmos/cosmos-sdk/simapp/simd/cmd" "github.com/likecoin/likechain/ip" + + serverconfig "github.com/cosmos/cosmos-sdk/server/config" ) // liked custom flags @@ -135,6 +137,21 @@ func txCommand() *cobra.Command { return txCmd } +// initAppConfig helps to override default appConfig template and configs. +// return "", nil if no custom configuration is required for the application. +func initAppConfig() (string, interface{}) { + srvCfg := serverconfig.DefaultConfig() + + srvCfg.MinGasPrices = "1nanolike" + + srvCfg.StateSync.SnapshotInterval = 1000 + srvCfg.StateSync.SnapshotKeepRecent = 2 + + customAppTemplate := serverconfig.DefaultConfigTemplate + + return customAppTemplate, srvCfg +} + func NewRootCmd() (*cobra.Command, app.EncodingConfig) { encodingConfig := app.MakeEncodingConfig() @@ -156,7 +173,9 @@ func NewRootCmd() (*cobra.Command, app.EncodingConfig) { return err } - return server.InterceptConfigsPreRunHandler(cmd, "", nil) + customAppTemplate, customAppConfig := initAppConfig() + + return server.InterceptConfigsPreRunHandler(cmd, customAppTemplate, customAppConfig) }, }