diff --git a/accounts/manager.go b/accounts/manager.go index 14c616d3d0..ebf7bbd62c 100644 --- a/accounts/manager.go +++ b/accounts/manager.go @@ -18,6 +18,7 @@ package accounts import ( "reflect" + "slices" "sort" "sync" @@ -254,13 +255,12 @@ func merge(slice []Wallet, wallets ...Wallet) []Wallet { // drop is the counterpart of merge, which looks up wallets from within the sorted // cache and removes the ones specified. func drop(slice []Wallet, wallets ...Wallet) []Wallet { - for _, wallet := range wallets { - n := sort.Search(len(slice), func(i int) bool { return slice[i].URL().Cmp(wallet.URL()) >= 0 }) - if n == len(slice) || slice[n].URL().Cmp(wallet.URL()) != 0 { - // Wallet not found, may happen during startup - continue - } - slice = append(slice[:n], slice[n+1:]...) + remove := make(map[URL]struct{}, len(wallets)) + for _, w := range wallets { + remove[w.URL()] = struct{}{} } - return slice + return slices.DeleteFunc(slice, func(w Wallet) bool { + _, ok := remove[w.URL()] + return ok + }) }