Skip to content

Commit

Permalink
1159 update state sync configs (#1160)
Browse files Browse the repository at this point in the history
* Update default snapshot configs

* Refactor

* Fix override to include default template

Co-authored-by: billy rennekamp <[email protected]>
  • Loading branch information
2 people authored and Yaru Wang committed Feb 10, 2022
1 parent e751312 commit 4678304
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion cmd/gaiad/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/cosmos/cosmos-sdk/client/keys"
"github.com/cosmos/cosmos-sdk/client/rpc"
"github.com/cosmos/cosmos-sdk/server"
serverconfig "github.com/cosmos/cosmos-sdk/server/config"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
"github.com/cosmos/cosmos-sdk/snapshots"
"github.com/cosmos/cosmos-sdk/store"
Expand Down Expand Up @@ -61,7 +62,8 @@ func NewRootCmd() (*cobra.Command, params.EncodingConfig) {
return err
}

return server.InterceptConfigsPreRunHandler(cmd, "", nil)
customTemplate, customGaiaConfig := initAppConfig()
return server.InterceptConfigsPreRunHandler(cmd, customTemplate, customGaiaConfig)
},
}

Expand All @@ -70,8 +72,27 @@ func NewRootCmd() (*cobra.Command, params.EncodingConfig) {
return rootCmd, encodingConfig
}

func initAppConfig() (string, interface{}) {

type CustomAppConfig struct {
serverconfig.Config
}

// Allow overrides to the SDK default server config
srvCfg := serverconfig.DefaultConfig()
srvCfg.StateSync.SnapshotInterval = 1000
srvCfg.StateSync.SnapshotKeepRecent = 10

GaiaAppCfg := CustomAppConfig{Config: *srvCfg}

GaiaAppTemplate := serverconfig.DefaultConfigTemplate

return GaiaAppTemplate, GaiaAppCfg
}

func initRootCmd(rootCmd *cobra.Command, encodingConfig params.EncodingConfig) {
cfg := sdk.GetConfig()

cfg.Seal()

rootCmd.AddCommand(
Expand Down

0 comments on commit 4678304

Please sign in to comment.