Skip to content

Commit

Permalink
Merge PR cosmos#5166: Add pruning constants and fix template
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderbez authored Oct 9, 2019
1 parent ee404e9 commit 8d7cc5e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
3 changes: 2 additions & 1 deletion server/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"strings"

"github.com/cosmos/cosmos-sdk/store"
sdk "github.com/cosmos/cosmos-sdk/types"
)

Expand Down Expand Up @@ -77,7 +78,7 @@ func DefaultConfig() *Config {
BaseConfig{
MinGasPrices: defaultMinGasPrices,
InterBlockCache: true,
Pruning: "syncable",
Pruning: store.PruningStrategySyncable,
},
}
}
2 changes: 1 addition & 1 deletion server/config/toml.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ inter-block-cache = {{ .BaseConfig.InterBlockCache }}
# syncable: only those states not needed for state syncing will be deleted (keeps last 100 + every 10000th)
# nothing: all historic states will be saved, nothing will be deleted (i.e. archiving node)
# everything: all saved states will be deleted, storing only the current state
pruning = {{ .BaseConfig.Pruning }}
pruning = "{{ .BaseConfig.Pruning }}"
`

var configTemplate *template.Template
Expand Down
13 changes: 10 additions & 3 deletions store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ import (
"github.com/cosmos/cosmos-sdk/store/types"
)

// Pruning strategies that may be provided to a KVStore to enable pruning.
const (
PruningStrategyNothing = "nothing"
PruningStrategyEverything = "everything"
PruningStrategySyncable = "syncable"
)

func NewCommitMultiStore(db dbm.DB) types.CommitMultiStore {
return rootmulti.NewStore(db)
}
Expand All @@ -18,11 +25,11 @@ func NewCommitKVStoreCacheManager() types.MultiStorePersistentCache {

func NewPruningOptionsFromString(strategy string) (opt PruningOptions) {
switch strategy {
case "nothing":
case PruningStrategyNothing:
opt = PruneNothing
case "everything":
case PruningStrategyEverything:
opt = PruneEverything
case "syncable":
case PruningStrategySyncable:
opt = PruneSyncable
default:
opt = PruneSyncable
Expand Down

0 comments on commit 8d7cc5e

Please sign in to comment.