mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
Let Wallet call walletsNoLock to avoid double read lock
This commit is contained in:
parent
34bb132b10
commit
928b4bfba8
1 changed files with 6 additions and 1 deletions
|
|
@ -141,6 +141,11 @@ func (am *Manager) Wallets() []Wallet {
|
|||
am.lock.RLock()
|
||||
defer am.lock.RUnlock()
|
||||
|
||||
return am.walletsNoLock()
|
||||
}
|
||||
|
||||
// Wallets without lock.
|
||||
func (am *Manager) walletsNoLock() []Wallet {
|
||||
cpy := make([]Wallet, len(am.wallets))
|
||||
copy(cpy, am.wallets)
|
||||
return cpy
|
||||
|
|
@ -155,7 +160,7 @@ func (am *Manager) Wallet(url string) (Wallet, error) {
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for _, wallet := range am.Wallets() {
|
||||
for _, wallet := range am.walletsNoLock() {
|
||||
if wallet.URL() == parsed {
|
||||
return wallet, nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue