Make sure WakuEnabled is respected on upgrade

This commit is contained in:
Andrea Maria Piana 2020-03-30 13:42:21 +02:00
parent 070a5adbee
commit 44272944ab
2 changed files with 18 additions and 2 deletions

View file

@ -1 +1 @@
0.50.1
0.50.2

View file

@ -371,10 +371,26 @@ func (b *GethStatusBackend) loadNodeConfig() (*params.NodeConfig, error) {
b.mu.Lock()
defer b.mu.Unlock()
var conf params.NodeConfig
err := accounts.NewDB(b.appDB).GetNodeConfig(&conf)
accountDB := accounts.NewDB(b.appDB)
err := accountDB.GetNodeConfig(&conf)
if err != nil {
return nil, err
}
settings, err := accountDB.GetSettings()
if err != nil {
return nil, err
}
// NodeConfig is denormalized and we can't migrate it easily
// WakuEnabled is pulled from settings and it's the source
// of truth on whether `WakuConfig` or `WhisperConfig` should be enabled
if settings.WakuEnabled {
conf.WakuConfig.Enabled = true
conf.WhisperConfig.Enabled = false
} else {
conf.WakuConfig.Enabled = false
conf.WhisperConfig.Enabled = true
}
// NodeConfig.Version should be taken from params.Version
// which is set at the compile time.
// What's cached is usually outdated so we overwrite it here.