aboutsummaryrefslogtreecommitdiffstats
path: root/accounts/manager.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2017-02-08 21:53:02 +0800
committerPéter Szilágyi <peterke@gmail.com>2017-02-13 20:00:08 +0800
commitc5215fdd48231622dd56aba63a5187c6e42828d4 (patch)
tree98bdb47dccb9ef3deaa571585c32db9d19166a80 /accounts/manager.go
parentfad5eb0a87abfc12812647344a26de8a43830182 (diff)
downloadgo-tangerine-c5215fdd48231622dd56aba63a5187c6e42828d4.tar.gz
go-tangerine-c5215fdd48231622dd56aba63a5187c6e42828d4.tar.zst
go-tangerine-c5215fdd48231622dd56aba63a5187c6e42828d4.zip
accounts, cmd, internal, mobile, node: canonical account URLs
Diffstat (limited to 'accounts/manager.go')
-rw-r--r--accounts/manager.go10
1 files changed, 7 insertions, 3 deletions
diff --git a/accounts/manager.go b/accounts/manager.go
index 0822500eb..12a5bfcd9 100644
--- a/accounts/manager.go
+++ b/accounts/manager.go
@@ -134,8 +134,12 @@ func (am *Manager) Wallet(url string) (Wallet, error) {
am.lock.RLock()
defer am.lock.RUnlock()
+ parsed, err := parseURL(url)
+ if err != nil {
+ return nil, err
+ }
for _, wallet := range am.Wallets() {
- if wallet.URL() == url {
+ if wallet.URL() == parsed {
return wallet, nil
}
}
@@ -169,7 +173,7 @@ func (am *Manager) Subscribe(sink chan<- WalletEvent) event.Subscription {
// The original slice is assumed to be already sorted by URL.
func merge(slice []Wallet, wallets ...Wallet) []Wallet {
for _, wallet := range wallets {
- n := sort.Search(len(slice), func(i int) bool { return slice[i].URL() >= wallet.URL() })
+ n := sort.Search(len(slice), func(i int) bool { return slice[i].URL().Cmp(wallet.URL()) >= 0 })
if n == len(slice) {
slice = append(slice, wallet)
continue
@@ -183,7 +187,7 @@ func merge(slice []Wallet, wallets ...Wallet) []Wallet {
// 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() >= wallet.URL() })
+ n := sort.Search(len(slice), func(i int) bool { return slice[i].URL().Cmp(wallet.URL()) >= 0 })
if n == len(slice) {
// Wallet not found, may happen during startup
continue