Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
whqwjb
go-ethereum
提交
6498df7b
G
go-ethereum
项目概览
whqwjb
/
go-ethereum
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
go-ethereum
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6498df7b
编写于
4月 07, 2016
作者:
F
Felix Lange
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
accounts: ensure TimedUnlock does not override indefinite unlock timeout
上级
46df50be
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
16 addition
and
10 deletion
+16
-10
accounts/account_manager.go
accounts/account_manager.go
+14
-8
accounts/accounts_test.go
accounts/accounts_test.go
+2
-2
未找到文件。
accounts/account_manager.go
浏览文件 @
6498df7b
...
...
@@ -164,14 +164,15 @@ func (am *Manager) Lock(addr common.Address) error {
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
// 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
// the active unlock timeout.
func
(
am
*
Manager
)
TimedUnlock
(
a
Account
,
keyAuth
string
,
timeout
time
.
Duration
)
error
{
_
,
key
,
err
:=
am
.
getDecryptedKey
(
a
,
keyAuth
)
// If the account address is already unlocked for a duration, TimedUnlock extends or
// shortens the active unlock timeout. If the address was previously unlocked
// indefinitely the timeout is not altered.
func
(
am
*
Manager
)
TimedUnlock
(
a
Account
,
passphrase
string
,
timeout
time
.
Duration
)
error
{
a
,
key
,
err
:=
am
.
getDecryptedKey
(
a
,
passphrase
)
if
err
!=
nil
{
return
err
}
...
...
@@ -180,8 +181,13 @@ func (am *Manager) TimedUnlock(a Account, keyAuth string, timeout time.Duration)
defer
am
.
mu
.
Unlock
()
u
,
found
:=
am
.
unlocked
[
a
.
Address
]
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
)
}
}
...
...
accounts/accounts_test.go
浏览文件 @
6498df7b
...
...
@@ -120,8 +120,8 @@ func TestOverrideUnlock(t *testing.T) {
pass
:=
"foo"
a1
,
err
:=
am
.
NewAccount
(
pass
)
// Unlock indefinitely
if
err
=
am
.
Unlock
(
a1
,
pass
);
err
!=
nil
{
// Unlock indefinitely
.
if
err
=
am
.
TimedUnlock
(
a1
,
pass
,
5
*
time
.
Minute
);
err
!=
nil
{
t
.
Fatal
(
err
)
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录