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
6684ef20
Commit
6684ef20
authored
Mar 08, 2015
by
Felix Lange
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
accounts: don't store address in unlocked and add commentary
This was suggested during review.
parent
fb53a936
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
8 deletions
+10
-8
account_manager.go
accounts/account_manager.go
+10
-8
No files found.
accounts/account_manager.go
View file @
6684ef20
...
...
@@ -60,10 +60,8 @@ type Manager struct {
}
type
unlocked
struct
{
addr
[]
byte
abort
chan
struct
{}
*
crypto
.
Key
abort
chan
struct
{}
}
func
NewManager
(
keyStore
crypto
.
KeyStore2
,
unlockTime
time
.
Duration
)
*
Manager
{
...
...
@@ -119,7 +117,7 @@ func (am *Manager) SignLocked(a Account, keyAuth string, toSign []byte) (signatu
return
nil
,
err
}
u
:=
am
.
addUnlocked
(
a
.
Address
,
key
)
go
am
.
dropLater
(
u
)
go
am
.
dropLater
(
a
.
Address
,
u
)
signature
,
err
=
crypto
.
Sign
(
toSign
,
key
.
PrivateKey
)
return
signature
,
err
}
...
...
@@ -149,7 +147,7 @@ func (am *Manager) Accounts() ([]Account, error) {
}
func
(
am
*
Manager
)
addUnlocked
(
addr
[]
byte
,
key
*
crypto
.
Key
)
*
unlocked
{
u
:=
&
unlocked
{
addr
:
addr
,
abort
:
make
(
chan
struct
{}),
Key
:
key
}
u
:=
&
unlocked
{
Key
:
key
,
abort
:
make
(
chan
struct
{})
}
am
.
mutex
.
Lock
()
prev
,
found
:=
am
.
unlocked
[
string
(
addr
)]
if
found
{
...
...
@@ -162,7 +160,7 @@ func (am *Manager) addUnlocked(addr []byte, key *crypto.Key) *unlocked {
return
u
}
func
(
am
*
Manager
)
dropLater
(
u
*
unlocked
)
{
func
(
am
*
Manager
)
dropLater
(
addr
[]
byte
,
u
*
unlocked
)
{
t
:=
time
.
NewTimer
(
am
.
unlockTime
)
defer
t
.
Stop
()
select
{
...
...
@@ -170,9 +168,13 @@ func (am *Manager) dropLater(u *unlocked) {
// just quit
case
<-
t
.
C
:
am
.
mutex
.
Lock
()
if
am
.
unlocked
[
string
(
u
.
addr
)]
==
u
{
// only drop if it's still the same key instance that dropLater
// was launched with. we can check that using pointer equality
// because the map stores a new pointer every time the key is
// unlocked.
if
am
.
unlocked
[
string
(
addr
)]
==
u
{
zeroKey
(
u
.
PrivateKey
)
delete
(
am
.
unlocked
,
string
(
u
.
addr
))
delete
(
am
.
unlocked
,
string
(
addr
))
}
am
.
mutex
.
Unlock
()
}
...
...
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