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
d648e96b
Commit
d648e96b
authored
Dec 01, 2015
by
Felix Lange
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cmd/utils: restore starting geth without any accounts and etherbase
Also remove some duplication around address/index parsing.
parent
f4a6470a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
21 deletions
+18
-21
main.go
cmd/geth/main.go
+5
-2
flags.go
cmd/utils/flags.go
+13
-19
No files found.
cmd/geth/main.go
View file @
d648e96b
...
...
@@ -464,9 +464,12 @@ func execScripts(ctx *cli.Context) {
node
.
Stop
()
}
// tries unlocking the specified account a few times.
func
unlockAccount
(
ctx
*
cli
.
Context
,
accman
*
accounts
.
Manager
,
address
string
,
i
int
,
passwords
[]
string
)
(
common
.
Address
,
string
)
{
// Try to unlock the specified account a few times
account
:=
utils
.
MakeAddress
(
accman
,
address
)
account
,
err
:=
utils
.
MakeAddress
(
accman
,
address
)
if
err
!=
nil
{
utils
.
Fatalf
(
"Unlock error: %v"
,
err
)
}
for
trials
:=
0
;
trials
<
3
;
trials
++
{
prompt
:=
fmt
.
Sprintf
(
"Unlocking account %s | Attempt %d/%d"
,
address
,
trials
+
1
,
3
)
...
...
cmd/utils/flags.go
View file @
d648e96b
...
...
@@ -518,47 +518,41 @@ func MakeAccountManager(ctx *cli.Context) *accounts.Manager {
// MakeAddress converts an account specified directly as a hex encoded string or
// a key index in the key store to an internal account representation.
func
MakeAddress
(
accman
*
accounts
.
Manager
,
account
string
)
common
.
Address
{
func
MakeAddress
(
accman
*
accounts
.
Manager
,
account
string
)
(
a
common
.
Address
,
err
error
)
{
// If the specified account is a valid address, return it
if
common
.
IsHexAddress
(
account
)
{
return
common
.
HexToAddress
(
account
)
return
common
.
HexToAddress
(
account
)
,
nil
}
// Otherwise try to interpret the account as a keystore index
index
,
err
:=
strconv
.
Atoi
(
account
)
if
err
!=
nil
{
Fatalf
(
"Invalid account address or index: '%s'
"
,
account
)
return
a
,
fmt
.
Errorf
(
"invalid account address or index %q
"
,
account
)
}
hex
,
err
:=
accman
.
AddressByIndex
(
index
)
if
err
!=
nil
{
Fatalf
(
"Failed to retrieve requested account #%d: %v
"
,
index
,
err
)
return
a
,
fmt
.
Errorf
(
"can't get account #%d (%v)
"
,
index
,
err
)
}
return
common
.
HexToAddress
(
hex
)
return
common
.
HexToAddress
(
hex
)
,
nil
}
// MakeEtherbase retrieves the etherbase either from the directly specified
// command line flags or from the keystore if CLI indexed.
func
MakeEtherbase
(
accman
*
accounts
.
Manager
,
ctx
*
cli
.
Context
)
common
.
Address
{
// If the specified etherbase is a valid address, return it
etherbase
:=
ctx
.
GlobalString
(
EtherbaseFlag
.
Name
)
if
common
.
IsHexAddress
(
etherbase
)
{
return
common
.
HexToAddress
(
etherbase
)
}
// If no etherbase was specified and no accounts are known, bail out
accounts
,
_
:=
accman
.
Accounts
()
if
etherbase
==
""
&&
len
(
accounts
)
==
0
{
if
!
ctx
.
GlobalIsSet
(
EtherbaseFlag
.
Name
)
&&
len
(
accounts
)
==
0
{
glog
.
V
(
logger
.
Error
)
.
Infoln
(
"WARNING: No etherbase set and no accounts found as default"
)
return
common
.
Address
{}
}
// Otherwise try to interpret the parameter as a keystore index
index
,
err
:=
strconv
.
Atoi
(
etherbase
)
if
err
!=
nil
{
Fatalf
(
"Invalid account address or index: '%s'"
,
etherbase
)
etherbase
:=
ctx
.
GlobalString
(
EtherbaseFlag
.
Name
)
if
etherbase
==
""
{
return
common
.
Address
{}
}
hex
,
err
:=
accman
.
AddressByIndex
(
index
)
// If the specified etherbase is a valid address, return it
addr
,
err
:=
MakeAddress
(
accman
,
etherbase
)
if
err
!=
nil
{
Fatalf
(
"
Failed to set requested account #%d as etherbase: %v"
,
index
,
err
)
Fatalf
(
"
Option %q: %v"
,
EtherbaseFlag
.
Name
,
err
)
}
return
common
.
HexToAddress
(
hex
)
return
addr
}
// MakeMinerExtra resolves extradata for the miner from the set command line flags
...
...
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