diff --git a/server/v2/store/commands.go b/server/v2/store/commands.go index cd3889185d38..cb52ab6cd4fe 100644 --- a/server/v2/store/commands.go +++ b/server/v2/store/commands.go @@ -36,7 +36,7 @@ Supported app-db-backend types include 'goleveldb', 'rocksdb', 'pebbledb'.`, Args: cobra.RangeArgs(0, 1), RunE: func(cmd *cobra.Command, args []string) error { // bind flags to the Context's Viper so we can get pruning options. - vp := viper.New() + vp := serverv2.GetViperFromCmd(cmd) if err := vp.BindPFlags(cmd.Flags()); err != nil { return err } diff --git a/server/v2/store/config.go b/server/v2/store/config.go new file mode 100644 index 000000000000..b065292fc2cd --- /dev/null +++ b/server/v2/store/config.go @@ -0,0 +1,22 @@ +package store + +import ( + pruningtypes "cosmossdk.io/store/pruning/types" +) + +func DefaultConfig() *Config { + return &Config{ + Pruning: pruningtypes.PruningOptionDefault, + AppDBBackend: "", + PruningKeepRecent: 0, + PruningInterval: 0, + } +} + + +type Config struct { + Pruning string `mapstructure:"pruning" toml:"pruning"` + AppDBBackend string `mapstructure:"app-db-backend" toml:"app-db-backend"` + PruningKeepRecent uint64 `mapstructure:"pruning-keep-recent" toml:"pruning-keep-recent"` + PruningInterval uint64 `mapstructure:"pruning-interval" toml:"pruning-interval"` +} \ No newline at end of file diff --git a/server/v2/store/server.go b/server/v2/store/server.go index 3257694e6c5a..ab4e4d5ce2ca 100644 --- a/server/v2/store/server.go +++ b/server/v2/store/server.go @@ -11,7 +11,9 @@ import ( serverv2 "cosmossdk.io/server/v2" ) -type StoreComponent struct{} +type StoreComponent struct{ + config *Config +} func New() serverv2.ServerComponent[transaction.Tx] { return StoreComponent{} @@ -40,3 +42,11 @@ func (s StoreComponent) CLICommands(appCreator serverv2.AppCreator[transaction.T }, } } + +func (g StoreComponent) Config() any { + if g.config == nil || g.config == (&Config{}) { + return DefaultConfig() + } + + return g.config +}