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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
bor
Commits
6498df7b
Commit
6498df7b
authored
8 years ago
by
Felix Lange
Browse files
Options
Downloads
Patches
Plain Diff
accounts: ensure TimedUnlock does not override indefinite unlock timeout
parent
46df50be
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
accounts/account_manager.go
+14
-8
14 additions, 8 deletions
accounts/account_manager.go
accounts/accounts_test.go
+2
-2
2 additions, 2 deletions
accounts/accounts_test.go
with
16 additions
and
10 deletions
accounts/account_manager.go
+
14
−
8
View file @
6498df7b
...
@@ -164,14 +164,15 @@ func (am *Manager) Lock(addr common.Address) error {
...
@@ -164,14 +164,15 @@ func (am *Manager) Lock(addr common.Address) error {
return
nil
return
nil
}
}
// TimedUnlock unlocks the given account with. The account
// TimedUnlock unlocks the given account with
the passphrase
. The account
// stays unlocked for the duration of timeout. A timeout of 0 unlocks the account
// stays unlocked for the duration of timeout. A timeout of 0 unlocks the account
// until the program exits. The account must match a unique key.
// until the program exits. The account must match a unique key
file
.
//
//
// If the accout is already unlocked, TimedUnlock extends or shortens
// If the account address is already unlocked for a duration, TimedUnlock extends or
// the active unlock timeout.
// shortens the active unlock timeout. If the address was previously unlocked
func
(
am
*
Manager
)
TimedUnlock
(
a
Account
,
keyAuth
string
,
timeout
time
.
Duration
)
error
{
// indefinitely the timeout is not altered.
_
,
key
,
err
:=
am
.
getDecryptedKey
(
a
,
keyAuth
)
func
(
am
*
Manager
)
TimedUnlock
(
a
Account
,
passphrase
string
,
timeout
time
.
Duration
)
error
{
a
,
key
,
err
:=
am
.
getDecryptedKey
(
a
,
passphrase
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
@@ -180,8 +181,13 @@ func (am *Manager) TimedUnlock(a Account, keyAuth string, timeout time.Duration)
...
@@ -180,8 +181,13 @@ func (am *Manager) TimedUnlock(a Account, keyAuth string, timeout time.Duration)
defer
am
.
mu
.
Unlock
()
defer
am
.
mu
.
Unlock
()
u
,
found
:=
am
.
unlocked
[
a
.
Address
]
u
,
found
:=
am
.
unlocked
[
a
.
Address
]
if
found
{
if
found
{
// terminate dropLater for this key to avoid unexpected drops.
if
u
.
abort
==
nil
{
if
u
.
abort
!=
nil
{
// The address was unlocked indefinitely, so unlocking
// it with a timeout would be confusing.
zeroKey
(
key
.
PrivateKey
)
return
nil
}
else
{
// Terminate the expire goroutine and replace it below.
close
(
u
.
abort
)
close
(
u
.
abort
)
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
accounts/accounts_test.go
+
2
−
2
View file @
6498df7b
...
@@ -120,8 +120,8 @@ func TestOverrideUnlock(t *testing.T) {
...
@@ -120,8 +120,8 @@ func TestOverrideUnlock(t *testing.T) {
pass
:=
"foo"
pass
:=
"foo"
a1
,
err
:=
am
.
NewAccount
(
pass
)
a1
,
err
:=
am
.
NewAccount
(
pass
)
// Unlock indefinitely
// Unlock indefinitely
.
if
err
=
am
.
Unlock
(
a1
,
pass
);
err
!=
nil
{
if
err
=
am
.
Timed
Unlock
(
a1
,
pass
,
5
*
time
.
Minute
);
err
!=
nil
{
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
}
}
...
...
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