From 0709d508a84a48ebf9e6bb1a49f34be34055199b Mon Sep 17 00:00:00 2001 From: martonp Date: Tue, 17 Jan 2023 15:17:05 -0500 Subject: [PATCH] cient/eth: Update wallet config after reconfigure When reconfiguring, the wallet settings on the baseWallet type were not being updated. When updating the RPC providers list on an unconnected wallet, the new providers were not being stored, so on Connect, it would attempt to connect to the old providers list. --- client/asset/eth/eth.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/client/asset/eth/eth.go b/client/asset/eth/eth.go index 95e43c2343..e51bbf159c 100644 --- a/client/asset/eth/eth.go +++ b/client/asset/eth/eth.go @@ -401,7 +401,9 @@ type baseWallet struct { log dex.Logger dir string walletType string - settings map[string]string + + settingsMtx sync.RWMutex + settings map[string]string gasFeeLimitV uint64 // atomic @@ -741,6 +743,8 @@ func (w *ETHWallet) Connect(ctx context.Context) (_ *sync.WaitGroup, err error) // } return nil, asset.ErrWalletTypeDisabled case walletTypeRPC: + w.settingsMtx.RLock() + defer w.settingsMtx.RUnlock() endpoints := strings.Split(w.settings[providersKey], " ") ethCfg, err := ethChainConfig(w.net) if err != nil { @@ -861,6 +865,10 @@ func (w *ETHWallet) Reconfigure(ctx context.Context, cfg *asset.WalletConfig, cu } } + w.settingsMtx.Lock() + w.settings = cfg.Settings + w.settingsMtx.Unlock() + atomic.StoreUint64(&w.baseWallet.gasFeeLimitV, gasFeeLimit) return false, nil