Skip to content

Commit

Permalink
cient/eth: Update wallet config after reconfigure
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
martonp authored and chappjc committed Jan 19, 2023
1 parent df8c5e6 commit 0709d50
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion client/asset/eth/eth.go
Expand Up @@ -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

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 0709d50

Please sign in to comment.