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
bedf6f40
Commit
bedf6f40
authored
Nov 20, 2017
by
Martin Holst Swende
Committed by
Felix Lange
Nov 20, 2017
Browse files
Options
Downloads
Patches
Plain Diff
cmd/geth: make geth account new faster with many keys (#15529)
parent
b4f2e4de
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
accounts/keystore/keystore_passphrase.go
+7
-0
7 additions, 0 deletions
accounts/keystore/keystore_passphrase.go
cmd/geth/accountcmd.go
+17
-4
17 additions, 4 deletions
cmd/geth/accountcmd.go
node/config.go
+22
-14
22 additions, 14 deletions
node/config.go
with
46 additions
and
18 deletions
accounts/keystore/keystore_passphrase.go
+
7
−
0
View file @
bedf6f40
...
...
@@ -28,6 +28,7 @@ package keystore
import
(
"bytes"
"crypto/aes"
crand
"crypto/rand"
"crypto/sha256"
"encoding/hex"
"encoding/json"
...
...
@@ -90,6 +91,12 @@ func (ks keyStorePassphrase) GetKey(addr common.Address, filename, auth string)
return
key
,
nil
}
// StoreKey generates a key, encrypts with 'auth' and stores in the given directory
func
StoreKey
(
dir
,
auth
string
,
scryptN
,
scryptP
int
)
(
common
.
Address
,
error
)
{
_
,
a
,
err
:=
storeNewKey
(
&
keyStorePassphrase
{
dir
,
scryptN
,
scryptP
},
crand
.
Reader
,
auth
)
return
a
.
Address
,
err
}
func
(
ks
keyStorePassphrase
)
StoreKey
(
filename
string
,
key
*
Key
,
auth
string
)
error
{
keyjson
,
err
:=
EncryptKey
(
key
,
auth
,
ks
.
scryptN
,
ks
.
scryptP
)
if
err
!=
nil
{
...
...
This diff is collapsed.
Click to expand it.
cmd/geth/accountcmd.go
+
17
−
4
View file @
bedf6f40
...
...
@@ -291,15 +291,28 @@ func ambiguousAddrRecovery(ks *keystore.KeyStore, err *keystore.AmbiguousAddrErr
// accountCreate creates a new account into the keystore defined by the CLI flags.
func
accountCreate
(
ctx
*
cli
.
Context
)
error
{
stack
,
_
:=
makeConfigNode
(
ctx
)
cfg
:=
gethConfig
{
Node
:
defaultNodeConfig
()}
// Load config file.
if
file
:=
ctx
.
GlobalString
(
configFileFlag
.
Name
);
file
!=
""
{
if
err
:=
loadConfig
(
file
,
&
cfg
);
err
!=
nil
{
utils
.
Fatalf
(
"%v"
,
err
)
}
}
utils
.
SetNodeConfig
(
ctx
,
&
cfg
.
Node
)
scryptN
,
scryptP
,
keydir
,
err
:=
cfg
.
Node
.
AccountConfig
()
if
err
!=
nil
{
utils
.
Fatalf
(
"Failed to read configuration: %v"
,
err
)
}
password
:=
getPassPhrase
(
"Your new account is locked with a password. Please give a password. Do not forget this password."
,
true
,
0
,
utils
.
MakePasswordList
(
ctx
))
ks
:=
stack
.
AccountManager
()
.
Backends
(
keystore
.
Key
Store
Type
)[
0
]
.
(
*
keystore
.
KeyStore
)
account
,
err
:=
ks
.
NewAccount
(
password
)
address
,
err
:=
keystore
.
Store
Key
(
keydir
,
password
,
scryptN
,
scryptP
)
if
err
!=
nil
{
utils
.
Fatalf
(
"Failed to create account: %v"
,
err
)
}
fmt
.
Printf
(
"Address: {%x}
\n
"
,
a
ccount
.
A
ddress
)
fmt
.
Printf
(
"Address: {%x}
\n
"
,
address
)
return
nil
}
...
...
This diff is collapsed.
Click to expand it.
node/config.go
+
22
−
14
View file @
bedf6f40
...
...
@@ -360,35 +360,43 @@ func (c *Config) parsePersistentNodes(path string) []*discover.Node {
return
nodes
}
func
makeAccountManager
(
conf
*
Config
)
(
*
accounts
.
Manager
,
string
,
error
)
{
// AccountConfig determines the settings for scrypt and keydirectory
func
(
c
*
Config
)
AccountConfig
()
(
int
,
int
,
string
,
error
)
{
scryptN
:=
keystore
.
StandardScryptN
scryptP
:=
keystore
.
StandardScryptP
if
c
onf
.
UseLightweightKDF
{
if
c
.
UseLightweightKDF
{
scryptN
=
keystore
.
LightScryptN
scryptP
=
keystore
.
LightScryptP
}
var
(
keydir
string
ephemeral
string
err
error
)
switch
{
case
filepath
.
IsAbs
(
c
onf
.
KeyStoreDir
)
:
keydir
=
c
onf
.
KeyStoreDir
case
c
onf
.
DataDir
!=
""
:
if
c
onf
.
KeyStoreDir
==
""
{
keydir
=
filepath
.
Join
(
c
onf
.
DataDir
,
datadirDefaultKeyStore
)
case
filepath
.
IsAbs
(
c
.
KeyStoreDir
)
:
keydir
=
c
.
KeyStoreDir
case
c
.
DataDir
!=
""
:
if
c
.
KeyStoreDir
==
""
{
keydir
=
filepath
.
Join
(
c
.
DataDir
,
datadirDefaultKeyStore
)
}
else
{
keydir
,
err
=
filepath
.
Abs
(
conf
.
KeyStoreDir
)
keydir
,
err
=
filepath
.
Abs
(
c
.
KeyStoreDir
)
}
case
c
.
KeyStoreDir
!=
""
:
keydir
,
err
=
filepath
.
Abs
(
c
.
KeyStoreDir
)
}
return
scryptN
,
scryptP
,
keydir
,
err
}
case
conf
.
KeyStoreDir
!=
""
:
keydir
,
err
=
filepath
.
Abs
(
conf
.
KeyStoreDir
)
default
:
func
makeAccountManager
(
conf
*
Config
)
(
*
accounts
.
Manager
,
string
,
error
)
{
scryptN
,
scryptP
,
keydir
,
err
:=
conf
.
AccountConfig
()
var
ephemeral
string
if
keydir
==
""
{
// There is no datadir.
keydir
,
err
=
ioutil
.
TempDir
(
""
,
"go-ethereum-keystore"
)
ephemeral
=
keydir
}
if
err
!=
nil
{
return
nil
,
""
,
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