fix: ensure db opened in UpdateNodeConfigFleet (#4822)

This commit is contained in:
Igor Sirotin 2024-02-27 19:00:20 +00:00 committed by GitHub
parent c5371bd3a5
commit 4fb27ec53a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 3 deletions

View File

@ -624,7 +624,7 @@ func (b *GethStatusBackend) loginAccount(request *requests.Login) error {
defaultCfg.WalletConfig = buildWalletConfig(&request.WalletSecretsConfig) defaultCfg.WalletConfig = buildWalletConfig(&request.WalletSecretsConfig)
err = b.UpdateNodeConfigFleet(defaultCfg) err = b.UpdateNodeConfigFleet(acc, password, defaultCfg)
if err != nil { if err != nil {
return err return err
} }
@ -697,11 +697,16 @@ func (b *GethStatusBackend) loginAccount(request *requests.Login) error {
// UpdateNodeConfigFleet loads the fleet from the settings and updates the node configuration // UpdateNodeConfigFleet loads the fleet from the settings and updates the node configuration
// If the fleet in settings is empty, or not supported anymore, it will be overridden with the default fleet. // If the fleet in settings is empty, or not supported anymore, it will be overridden with the default fleet.
// In that case settings fleet value remain the same, only runtime node configuration is updated. // In that case settings fleet value remain the same, only runtime node configuration is updated.
func (b *GethStatusBackend) UpdateNodeConfigFleet(config *params.NodeConfig) error { func (b *GethStatusBackend) UpdateNodeConfigFleet(acc multiaccounts.Account, password string, config *params.NodeConfig) error {
if config == nil { if config == nil {
return nil return nil
} }
err := b.ensureDBsOpened(acc, password)
if err != nil {
return err
}
accountSettings, err := b.GetSettings() accountSettings, err := b.GetSettings()
if err != nil { if err != nil {
return err return err

View File

@ -231,7 +231,7 @@ func login(accountData, password, configJSON string) error {
api.RunAsync(func() error { api.RunAsync(func() error {
log.Debug("start a node with account", "key-uid", account.KeyUID) log.Debug("start a node with account", "key-uid", account.KeyUID)
err := statusBackend.UpdateNodeConfigFleet(&conf) err := statusBackend.UpdateNodeConfigFleet(account, password, &conf)
if err != nil { if err != nil {
return err return err
} }