Skip to content

Commit

Permalink
fix(server/v2/store): fix store server flags (#21745)
Browse files Browse the repository at this point in the history
  • Loading branch information
julienrbrt authored Sep 16, 2024
1 parent c0eced8 commit e49ecfe
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
2 changes: 1 addition & 1 deletion server/v2/store/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func createRootStore(cmd *cobra.Command, v *viper.Viper, logger log.Logger) (sto
}
dbType = db.DBType(dbStr)
} else {
dbType = db.DBType(v.GetString("store.app-db-backend"))
dbType = db.DBType(v.GetString(FlagAppDBBackend))
}
scRawDb, err := db.NewDB(dbType, "application", filepath.Join(rootDir, "data"), nil)
if err != nil {
Expand Down
17 changes: 13 additions & 4 deletions server/v2/store/flags.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
package store

const (
FlagAppDBBackend = "app-db-backend"
FlagKeepRecent = "keep-recent"
FlagInterval = "interval"
import "fmt"

// start flags are prefixed with the server name
// as the config in prefixed with the server name
// this allows viper to properly bind the flags
func prefix(f string) string {
return fmt.Sprintf("%s.%s", ServerName, f)
}

var (
FlagAppDBBackend = prefix("app-db-backend")
FlagKeepRecent = prefix("keep-recent")
FlagInterval = prefix("interval")
)
10 changes: 9 additions & 1 deletion server/v2/store/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ import (
serverv2 "cosmossdk.io/server/v2"
)

var (
_ serverv2.ServerComponent[transaction.Tx] = (*StoreComponent[transaction.Tx])(nil)
_ serverv2.HasConfig = (*StoreComponent[transaction.Tx])(nil)
_ serverv2.HasCLICommands = (*StoreComponent[transaction.Tx])(nil)
)

const ServerName = "store"

// StoreComponent manages store config
// and contains prune & snapshot commands
type StoreComponent[T transaction.Tx] struct {
Expand All @@ -35,7 +43,7 @@ func (s *StoreComponent[T]) Init(appI serverv2.AppI[T], cfg map[string]any, logg
}

func (s *StoreComponent[T]) Name() string {
return "store"
return ServerName
}

func (s *StoreComponent[T]) Start(ctx context.Context) error {
Expand Down

0 comments on commit e49ecfe

Please sign in to comment.