Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
b3c0e9d3
Unverified
Commit
b3c0e9d3
authored
Jan 30, 2017
by
Péter Szilágyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
accounts/usbwallet: two phase Ledger refreshes to avoid Windows bug
parent
470b7938
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
25 deletions
+24
-25
ledger.go
accounts/usbwallet/ledger.go
+24
-25
No files found.
accounts/usbwallet/ledger.go
View file @
b3c0e9d3
...
...
@@ -234,32 +234,11 @@ func (hub *LedgerHub) rescan() {
hub
.
lock
.
Lock
()
defer
hub
.
lock
.
Unlock
()
// Iterate over all attached devices and fetch those seemingly Ledger
present
:=
make
(
map
[
uint16
]
bool
)
devices
,
_
:=
hub
.
ctx
.
ListDevices
(
func
(
desc
*
usb
.
Descriptor
)
bool
{
// Discard all devices not advertizing as Ledger
ledger
:=
false
for
_
,
id
:=
range
ledgerDeviceIDs
{
if
desc
.
Vendor
==
id
.
Vendor
&&
desc
.
Product
==
id
.
Product
{
ledger
=
true
}
}
if
!
ledger
{
return
false
}
// If we have a Ledger, mark as still present, or open as new
id
:=
uint16
(
desc
.
Bus
)
<<
8
+
uint16
(
desc
.
Address
)
if
_
,
known
:=
hub
.
wallets
[
id
];
known
{
// Track it's presence, but don't open again
present
[
id
]
=
true
return
false
}
// New Ledger device, open it for communication
return
true
})
// Drop any tracker wallet which disconnected
// Iterate over all connected Ledger devices and do a heartbeat test
for
id
,
wallet
:=
range
hub
.
wallets
{
if
!
present
[
id
]
{
// If the device doesn't respond (io error on Windows, no device on Linux), drop
if
err
:=
wallet
.
resolveVersion
();
err
==
usb
.
ERROR_IO
||
err
==
usb
.
ERROR_NO_DEVICE
{
// Wallet disconnected or at least in a useless state
if
wallet
.
address
==
(
common
.
Address
{})
{
glog
.
V
(
logger
.
Info
)
.
Infof
(
"ledger wallet [%03d.%03d] disconnected"
,
wallet
.
device
.
Bus
,
wallet
.
device
.
Address
)
}
else
{
...
...
@@ -279,6 +258,26 @@ func (hub *LedgerHub) rescan() {
wallet
.
device
.
Close
()
}
}
// Iterate over all attached devices and fetch those seemingly Ledger
devices
,
_
:=
hub
.
ctx
.
ListDevices
(
func
(
desc
*
usb
.
Descriptor
)
bool
{
// Discard all devices not advertizing as Ledger
ledger
:=
false
for
_
,
id
:=
range
ledgerDeviceIDs
{
if
desc
.
Vendor
==
id
.
Vendor
&&
desc
.
Product
==
id
.
Product
{
ledger
=
true
}
}
if
!
ledger
{
return
false
}
// If we have an already known Ledger, skip opening it
id
:=
uint16
(
desc
.
Bus
)
<<
8
+
uint16
(
desc
.
Address
)
if
_
,
known
:=
hub
.
wallets
[
id
];
known
{
return
false
}
// New Ledger device, open it for communication
return
true
})
// Start tracking all wallets which newly appeared
var
err
error
for
_
,
device
:=
range
devices
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment