Merge PR #5166: Add pruning constants and fix template

This commit is contained in:
Alexander Bezobchuk 2019-10-09 15:57:12 -04:00 committed by GitHub
parent ee404e96ab
commit 8d7cc5e08d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 5 deletions

View File

@ -4,6 +4,7 @@ import (
"fmt"
"strings"
"github.com/cosmos/cosmos-sdk/store"
sdk "github.com/cosmos/cosmos-sdk/types"
)
@ -77,7 +78,7 @@ func DefaultConfig() *Config {
BaseConfig{
MinGasPrices: defaultMinGasPrices,
InterBlockCache: true,
Pruning: "syncable",
Pruning: store.PruningStrategySyncable,
},
}
}

View File

@ -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

View File

@ -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)
}
@ -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