From 4678304a0fcc81c25b3eef09b6ffdd966062a603 Mon Sep 17 00:00:00 2001 From: lg <8335464+glnro@users.noreply.github.com> Date: Wed, 19 Jan 2022 15:54:34 -0500 Subject: [PATCH] 1159 update state sync configs (#1160) * Update default snapshot configs * Refactor * Fix override to include default template Co-authored-by: billy rennekamp --- cmd/gaiad/cmd/root.go | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/cmd/gaiad/cmd/root.go b/cmd/gaiad/cmd/root.go index acefb957455..ebfd683738c 100644 --- a/cmd/gaiad/cmd/root.go +++ b/cmd/gaiad/cmd/root.go @@ -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" @@ -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) }, } @@ -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(