Skip to content

Commit

Permalink
accounts/external: fill account-cache if that hasn't already been done,
Browse files Browse the repository at this point in the history
  • Loading branch information
holiman authored and enriquefynn committed Feb 15, 2021
1 parent 8ac3b25 commit 3fcf487
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions accounts/external/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,12 @@ func (api *ExternalSigner) Accounts() []accounts.Account {
func (api *ExternalSigner) Contains(account accounts.Account) bool {
api.cacheMu.RLock()
defer api.cacheMu.RUnlock()
if api.cache == nil {
// If we haven't already fetched the accounts, it's time to do so now
api.cacheMu.RUnlock()
api.Accounts()
api.cacheMu.RLock()
}
for _, a := range api.cache {
if a.Address == account.Address && (account.URL == (accounts.URL{}) || account.URL == api.URL()) {
return true
Expand Down

0 comments on commit 3fcf487

Please sign in to comment.