Skip to content

Commit

Permalink
Set default server configs for min gas price and state sync snapshots
Browse files Browse the repository at this point in the history
Ref #115
  • Loading branch information
elise-ng committed Mar 25, 2022
1 parent 2417cf0 commit 4f2be58
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion cmd/liked/cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()

Expand All @@ -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)
},
}

Expand Down

0 comments on commit 4f2be58

Please sign in to comment.