good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
bor
Commits
b3c0e9d3
Unverified
Commit
b3c0e9d3
authored
Jan 30, 2017
by
Péter Szilágyi
Browse files
Options
Downloads
Patches
Plain Diff
accounts/usbwallet: two phase Ledger refreshes to avoid Windows bug
parent
470b7938
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
accounts/usbwallet/ledger.go
+24
-25
24 additions, 25 deletions
accounts/usbwallet/ledger.go
with
24 additions
and
25 deletions
accounts/usbwallet/ledger.go
+
24
−
25
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
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment