Skip to content

Commit 5f2002b

Browse files
author
Boqin Qin
authored
accounts: add walletsNoLock to avoid double read lock (#20655)
1 parent a9614c3 commit 5f2002b

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

accounts/manager.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,11 @@ func (am *Manager) Wallets() []Wallet {
141141
am.lock.RLock()
142142
defer am.lock.RUnlock()
143143

144+
return am.walletsNoLock()
145+
}
146+
147+
// walletsNoLock returns all registered wallets. Callers must hold am.lock.
148+
func (am *Manager) walletsNoLock() []Wallet {
144149
cpy := make([]Wallet, len(am.wallets))
145150
copy(cpy, am.wallets)
146151
return cpy
@@ -155,7 +160,7 @@ func (am *Manager) Wallet(url string) (Wallet, error) {
155160
if err != nil {
156161
return nil, err
157162
}
158-
for _, wallet := range am.Wallets() {
163+
for _, wallet := range am.walletsNoLock() {
159164
if wallet.URL() == parsed {
160165
return wallet, nil
161166
}

0 commit comments

Comments
 (0)