Skip to content

Commit

Permalink
godoc
Browse files Browse the repository at this point in the history
  • Loading branch information
hieuvubk committed Jul 19, 2024
1 parent 67cf8b4 commit 237ef66
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
14 changes: 7 additions & 7 deletions server/v2/store/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Supported app-db-backend types include 'goleveldb', 'rocksdb', 'pebbledb'.`,
return err
}

rootStore, err, interval := createRootStore(cmd, home, vp, logger)
rootStore, keepRecent, err := createRootStore(cmd, home, vp, logger)
if err != nil {
return fmt.Errorf("can not create root store %w", err)
}
Expand All @@ -64,7 +64,7 @@ Supported app-db-backend types include 'goleveldb', 'rocksdb', 'pebbledb'.`,
return fmt.Errorf("the database has no valid heights to prune, the latest height: %v", latestHeight)
}

upTo := latestHeight - interval
upTo := latestHeight - keepRecent
cmd.Printf("pruning heights up to %v\n", upTo)

err = rootStore.Prune(latestHeight)
Expand All @@ -83,7 +83,7 @@ Supported app-db-backend types include 'goleveldb', 'rocksdb', 'pebbledb'.`,
return cmd
}

func createRootStore(cmd *cobra.Command, rootDir string, v *viper.Viper, logger log.Logger) (storev2.RootStore, error, uint64) {
func createRootStore(cmd *cobra.Command, rootDir string, v *viper.Viper, logger log.Logger) (storev2.RootStore, uint64, error) {
tempViper := v
scRawDb, err := db.NewGoLevelDB("application", filepath.Join(rootDir, "data"), nil)
if err != nil {
Expand All @@ -94,7 +94,7 @@ func createRootStore(cmd *cobra.Command, rootDir string, v *viper.Viper, logger
if cmd.Flags().Changed(FlagPruningKeepRecent) {
keepRecent, err := cmd.Flags().GetUint64(FlagPruningKeepRecent)
if err != nil {
return nil, err, 0
return nil, 0, err
}

// viper has an issue that we could not override subitem then Unmarshal key
Expand All @@ -107,12 +107,12 @@ func createRootStore(cmd *cobra.Command, rootDir string, v *viper.Viper, logger

err = overrideKeepRecent(filepath.Join(rootDir, "config"), keepRecent)
if err != nil {
return nil, err, 0
return nil, 0, err
}

tempViper, err = serverv2.ReadConfig(filepath.Join(rootDir, "config"))
if err != nil {
return nil, err, 0
return nil, 0, err
}
}

Expand All @@ -123,7 +123,7 @@ func createRootStore(cmd *cobra.Command, rootDir string, v *viper.Viper, logger
SCRawDB: scRawDb,
})

return store, err, tempViper.GetUint64("store.options.sc-pruning-option.keep-recent")
return store, tempViper.GetUint64("store.options.sc-pruning-option.keep-recent"), err
}

func overrideKeepRecent(configPath string, keepRecent uint64) error {
Expand Down
2 changes: 2 additions & 0 deletions server/v2/store/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (
serverv2 "cosmossdk.io/server/v2"
)

// StoreComponent manages store config
// and contains prune & snapshot commands
type StoreComponent[T transaction.Tx] struct {
config *Config
}
Expand Down

0 comments on commit 237ef66

Please sign in to comment.