fix all bits broken by viper API changes (#5982)
github.com/spf13/viper's recent releases introduced a semantic
change in some public API such as viper.IsSet(), which have
broken some of our flags checks. Instead of checking whether
users have changed a flag's default value we should rely on such
defaults and adjust runtime behaviour accordingly. In order to do
so, it's important that we pick sane defaults for all our flags.
The --pruning flag and configuration option now allow for a
fake custom strategy. When users elect custom, then the
pruning-{keep,snapshot}-every options are interpreted and
parsed; else they're ignored.
Zero is pruning-{keep,snapshot}-every default value. When
users choose to set a custom pruning strategy they are
signalling that they want more fine-grainted control, therefore
it's legitimate to expect them to know what they are doing and
enter valid values for both options.
Ref #5964
This commit is contained in:
@@ -35,7 +35,9 @@ type BaseConfig struct {
|
||||
// InterBlockCache enables inter-block caching.
|
||||
InterBlockCache bool `mapstructure:"inter-block-cache"`
|
||||
|
||||
Pruning string `mapstructure:"pruning"`
|
||||
Pruning string `mapstructure:"pruning"`
|
||||
PruningKeepEvery string `mapstructure:"pruning-keep-every"`
|
||||
PruningSnapshotEvery string `mapstructure:"pruning-snapshot-every"`
|
||||
}
|
||||
|
||||
// Config defines the server's top level configuration
|
||||
@@ -74,9 +76,11 @@ func (c *Config) GetMinGasPrices() sdk.DecCoins {
|
||||
func DefaultConfig() *Config {
|
||||
return &Config{
|
||||
BaseConfig{
|
||||
MinGasPrices: defaultMinGasPrices,
|
||||
InterBlockCache: true,
|
||||
Pruning: store.PruningStrategySyncable,
|
||||
MinGasPrices: defaultMinGasPrices,
|
||||
InterBlockCache: true,
|
||||
Pruning: store.PruningStrategySyncable,
|
||||
PruningKeepEvery: "0",
|
||||
PruningSnapshotEvery: "0",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,11 +34,16 @@ halt-time = {{ .BaseConfig.HaltTime }}
|
||||
# InterBlockCache enables inter-block caching.
|
||||
inter-block-cache = {{ .BaseConfig.InterBlockCache }}
|
||||
|
||||
# Pruning sets the pruning strategy: syncable, nothing, everything
|
||||
# Pruning sets the pruning strategy: syncable, nothing, everything, custom
|
||||
# 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
|
||||
# custom: allows fine-grained control through the pruning-keep-every and pruning-snapshot-every options.
|
||||
pruning = "{{ .BaseConfig.Pruning }}"
|
||||
|
||||
# These are applied if and only if the pruning strategy is custom.
|
||||
pruning-keep-every = "{{ .BaseConfig.PruningKeepEvery }}"
|
||||
pruning-snapshot-every = "{{ .BaseConfig.PruningSnapshotEvery }}"
|
||||
`
|
||||
|
||||
var configTemplate *template.Template
|
||||
|
||||
Reference in New Issue
Block a user