accounts/external: fill account-cache if that hasn't already been done, fixes #20995 (#20998)

This commit is contained in:
Martin Holst Swende 2020-04-30 18:57:06 +02:00 committed by GitHub
parent 2337aa64eb
commit d2d3166f35
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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