diff options
author | Péter Szilágyi <peterke@gmail.com> | 2017-02-09 09:28:22 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2017-02-13 20:00:10 +0800 |
commit | fb1984685562479bfe2b041ae98f901525d1d9d3 (patch) | |
tree | d8f8fcc896ae6b6d93292e20a4594ea92c9074e2 /accounts/usbwallet/ledger_hub.go | |
parent | 205ea9580215cca4093dff22ec61222bc3a6ff96 (diff) | |
download | dexon-fb1984685562479bfe2b041ae98f901525d1d9d3.tar dexon-fb1984685562479bfe2b041ae98f901525d1d9d3.tar.gz dexon-fb1984685562479bfe2b041ae98f901525d1d9d3.tar.bz2 dexon-fb1984685562479bfe2b041ae98f901525d1d9d3.tar.lz dexon-fb1984685562479bfe2b041ae98f901525d1d9d3.tar.xz dexon-fb1984685562479bfe2b041ae98f901525d1d9d3.tar.zst dexon-fb1984685562479bfe2b041ae98f901525d1d9d3.zip |
accounts/usbwallet: Ledger teardown on health-check failure
Diffstat (limited to 'accounts/usbwallet/ledger_hub.go')
-rw-r--r-- | accounts/usbwallet/ledger_hub.go | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/accounts/usbwallet/ledger_hub.go b/accounts/usbwallet/ledger_hub.go index bd397249f..ad5940cd4 100644 --- a/accounts/usbwallet/ledger_hub.go +++ b/accounts/usbwallet/ledger_hub.go @@ -130,12 +130,12 @@ func (hub *LedgerHub) refreshWallets() { url := accounts.URL{Scheme: LedgerScheme, Path: fmt.Sprintf("%03d:%03d", busID>>8, busID&0xff)} - // Drop wallets while they were in front of the next account - for len(hub.wallets) > 0 && hub.wallets[0].URL().Cmp(url) < 0 { + // Drop wallets in front of the next device or those that failed for some reason + for len(hub.wallets) > 0 && (hub.wallets[0].URL().Cmp(url) < 0 || hub.wallets[0].(*ledgerWallet).failed()) { events = append(events, accounts.WalletEvent{Wallet: hub.wallets[0], Arrive: false}) hub.wallets = hub.wallets[1:] } - // If there are no more wallets or the account is before the next, wrap new wallet + // If there are no more wallets or the device is before the next, wrap new wallet if len(hub.wallets) == 0 || hub.wallets[0].URL().Cmp(url) > 0 { wallet := &ledgerWallet{context: hub.ctx, hardwareID: devID, locationID: busID, url: &url} @@ -143,7 +143,7 @@ func (hub *LedgerHub) refreshWallets() { wallets = append(wallets, wallet) continue } - // If the account is the same as the first wallet, keep it + // If the device is the same as the first wallet, keep it if hub.wallets[0].URL().Cmp(url) == 0 { wallets = append(wallets, hub.wallets[0]) hub.wallets = hub.wallets[1:] |