refactor!: abstractions for snapshot and pruning; snapshot intervals eventually pruned; unit tests (#11496)
This commit is contained in:
+7
-8
@@ -6,23 +6,22 @@ import (
|
||||
|
||||
"github.com/spf13/cast"
|
||||
|
||||
pruningtypes "github.com/cosmos/cosmos-sdk/pruning/types"
|
||||
"github.com/cosmos/cosmos-sdk/server/types"
|
||||
"github.com/cosmos/cosmos-sdk/store"
|
||||
storetypes "github.com/cosmos/cosmos-sdk/store/types"
|
||||
)
|
||||
|
||||
// GetPruningOptionsFromFlags parses command flags and returns the correct
|
||||
// PruningOptions. If a pruning strategy is provided, that will be parsed and
|
||||
// returned, otherwise, it is assumed custom pruning options are provided.
|
||||
func GetPruningOptionsFromFlags(appOpts types.AppOptions) (storetypes.PruningOptions, error) {
|
||||
func GetPruningOptionsFromFlags(appOpts types.AppOptions) (pruningtypes.PruningOptions, error) {
|
||||
strategy := strings.ToLower(cast.ToString(appOpts.Get(FlagPruning)))
|
||||
|
||||
switch strategy {
|
||||
case storetypes.PruningOptionDefault, storetypes.PruningOptionNothing, storetypes.PruningOptionEverything:
|
||||
return storetypes.NewPruningOptionsFromString(strategy), nil
|
||||
case pruningtypes.PruningOptionDefault, pruningtypes.PruningOptionNothing, pruningtypes.PruningOptionEverything:
|
||||
return pruningtypes.NewPruningOptionsFromString(strategy), nil
|
||||
|
||||
case storetypes.PruningOptionCustom:
|
||||
opts := storetypes.NewPruningOptions(
|
||||
case pruningtypes.PruningOptionCustom:
|
||||
opts := pruningtypes.NewCustomPruningOptions(
|
||||
cast.ToUint64(appOpts.Get(FlagPruningKeepRecent)),
|
||||
cast.ToUint64(appOpts.Get(FlagPruningInterval)),
|
||||
)
|
||||
@@ -34,6 +33,6 @@ func GetPruningOptionsFromFlags(appOpts types.AppOptions) (storetypes.PruningOpt
|
||||
return opts, nil
|
||||
|
||||
default:
|
||||
return store.PruningOptions{}, fmt.Errorf("unknown pruning strategy %s", strategy)
|
||||
return pruningtypes.PruningOptions{}, fmt.Errorf("unknown pruning strategy %s", strategy)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user