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
581c0901
Commit
581c0901
authored
Oct 01, 2015
by
Jeffrey Wilcke
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1856 from karalabe/andorid-path-fix
common: fix #1818, secondary datadir paths to fall back to
parents
e3ac56d5
74578ab2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
21 deletions
+41
-21
main.go
cmd/geth/main.go
+12
-12
flags.go
cmd/utils/flags.go
+13
-3
path.go
common/path.go
+16
-6
No files found.
cmd/geth/main.go
View file @
581c0901
...
...
@@ -390,7 +390,7 @@ func makeDefaultExtra() []byte {
}
func
run
(
ctx
*
cli
.
Context
)
{
utils
.
CheckLegalese
(
ctx
.
GlobalString
(
utils
.
DataDirFlag
.
Name
))
utils
.
CheckLegalese
(
utils
.
MustDataDir
(
ctx
))
if
ctx
.
GlobalBool
(
utils
.
OlympicFlag
.
Name
)
{
utils
.
InitOlympic
()
}
...
...
@@ -409,7 +409,7 @@ func run(ctx *cli.Context) {
}
func
attach
(
ctx
*
cli
.
Context
)
{
utils
.
CheckLegalese
(
ctx
.
GlobalString
(
utils
.
DataDirFlag
.
Name
))
utils
.
CheckLegalese
(
utils
.
MustDataDir
(
ctx
))
var
client
comms
.
EthereumClient
var
err
error
...
...
@@ -441,7 +441,7 @@ func attach(ctx *cli.Context) {
}
func
console
(
ctx
*
cli
.
Context
)
{
utils
.
CheckLegalese
(
ctx
.
GlobalString
(
utils
.
DataDirFlag
.
Name
))
utils
.
CheckLegalese
(
utils
.
MustDataDir
(
ctx
))
cfg
:=
utils
.
MakeEthConfig
(
ClientIdentifier
,
nodeNameVersion
,
ctx
)
cfg
.
ExtraData
=
makeExtra
(
ctx
)
...
...
@@ -475,7 +475,7 @@ func console(ctx *cli.Context) {
}
func
execJSFiles
(
ctx
*
cli
.
Context
)
{
utils
.
CheckLegalese
(
ctx
.
GlobalString
(
utils
.
DataDirFlag
.
Name
))
utils
.
CheckLegalese
(
utils
.
MustDataDir
(
ctx
))
cfg
:=
utils
.
MakeEthConfig
(
ClientIdentifier
,
nodeNameVersion
,
ctx
)
ethereum
,
err
:=
eth
.
New
(
cfg
)
...
...
@@ -502,7 +502,7 @@ func execJSFiles(ctx *cli.Context) {
}
func
unlockAccount
(
ctx
*
cli
.
Context
,
am
*
accounts
.
Manager
,
addr
string
,
i
int
)
(
addrHex
,
auth
string
)
{
utils
.
CheckLegalese
(
ctx
.
GlobalString
(
utils
.
DataDirFlag
.
Name
))
utils
.
CheckLegalese
(
utils
.
MustDataDir
(
ctx
))
var
err
error
addrHex
,
err
=
utils
.
ParamToAddress
(
addr
,
am
)
...
...
@@ -527,7 +527,7 @@ func unlockAccount(ctx *cli.Context, am *accounts.Manager, addr string, i int) (
}
func
blockRecovery
(
ctx
*
cli
.
Context
)
{
utils
.
CheckLegalese
(
ctx
.
GlobalString
(
utils
.
DataDirFlag
.
Name
))
utils
.
CheckLegalese
(
utils
.
MustDataDir
(
ctx
))
arg
:=
ctx
.
Args
()
.
First
()
if
len
(
ctx
.
Args
())
<
1
&&
len
(
arg
)
>
0
{
...
...
@@ -593,7 +593,7 @@ func startEth(ctx *cli.Context, eth *eth.Ethereum) {
}
func
accountList
(
ctx
*
cli
.
Context
)
{
utils
.
CheckLegalese
(
ctx
.
GlobalString
(
utils
.
DataDirFlag
.
Name
))
utils
.
CheckLegalese
(
utils
.
MustDataDir
(
ctx
))
am
:=
utils
.
MakeAccountManager
(
ctx
)
accts
,
err
:=
am
.
Accounts
()
...
...
@@ -643,7 +643,7 @@ func getPassPhrase(ctx *cli.Context, desc string, confirmation bool, i int) (pas
}
func
accountCreate
(
ctx
*
cli
.
Context
)
{
utils
.
CheckLegalese
(
ctx
.
GlobalString
(
utils
.
DataDirFlag
.
Name
))
utils
.
CheckLegalese
(
utils
.
MustDataDir
(
ctx
))
am
:=
utils
.
MakeAccountManager
(
ctx
)
passphrase
:=
getPassPhrase
(
ctx
,
"Your new account is locked with a password. Please give a password. Do not forget this password."
,
true
,
0
)
...
...
@@ -655,7 +655,7 @@ func accountCreate(ctx *cli.Context) {
}
func
accountUpdate
(
ctx
*
cli
.
Context
)
{
utils
.
CheckLegalese
(
ctx
.
GlobalString
(
utils
.
DataDirFlag
.
Name
))
utils
.
CheckLegalese
(
utils
.
MustDataDir
(
ctx
))
am
:=
utils
.
MakeAccountManager
(
ctx
)
arg
:=
ctx
.
Args
()
.
First
()
...
...
@@ -672,7 +672,7 @@ func accountUpdate(ctx *cli.Context) {
}
func
importWallet
(
ctx
*
cli
.
Context
)
{
utils
.
CheckLegalese
(
ctx
.
GlobalString
(
utils
.
DataDirFlag
.
Name
))
utils
.
CheckLegalese
(
utils
.
MustDataDir
(
ctx
))
keyfile
:=
ctx
.
Args
()
.
First
()
if
len
(
keyfile
)
==
0
{
...
...
@@ -694,7 +694,7 @@ func importWallet(ctx *cli.Context) {
}
func
accountImport
(
ctx
*
cli
.
Context
)
{
utils
.
CheckLegalese
(
ctx
.
GlobalString
(
utils
.
DataDirFlag
.
Name
))
utils
.
CheckLegalese
(
utils
.
MustDataDir
(
ctx
))
keyfile
:=
ctx
.
Args
()
.
First
()
if
len
(
keyfile
)
==
0
{
...
...
@@ -710,7 +710,7 @@ func accountImport(ctx *cli.Context) {
}
func
makedag
(
ctx
*
cli
.
Context
)
{
utils
.
CheckLegalese
(
ctx
.
GlobalString
(
utils
.
DataDirFlag
.
Name
))
utils
.
CheckLegalese
(
utils
.
MustDataDir
(
ctx
))
args
:=
ctx
.
Args
()
wrongArgs
:=
func
()
{
...
...
cmd/utils/flags.go
View file @
581c0901
...
...
@@ -416,7 +416,7 @@ func MakeEthConfig(clientID, version string, ctx *cli.Context) *eth.Config {
cfg
:=
&
eth
.
Config
{
Name
:
common
.
MakeName
(
clientID
,
version
),
DataDir
:
ctx
.
GlobalString
(
DataDirFlag
.
Name
),
DataDir
:
MustDataDir
(
ctx
),
GenesisNonce
:
ctx
.
GlobalInt
(
GenesisNonceFlag
.
Name
),
GenesisFile
:
ctx
.
GlobalString
(
GenesisFileFlag
.
Name
),
BlockChainVersion
:
ctx
.
GlobalInt
(
BlockchainVersionFlag
.
Name
),
...
...
@@ -509,7 +509,7 @@ func SetupEth(ctx *cli.Context) {
// MakeChain creates a chain manager from set command line flags.
func
MakeChain
(
ctx
*
cli
.
Context
)
(
chain
*
core
.
ChainManager
,
chainDb
ethdb
.
Database
)
{
datadir
:=
ctx
.
GlobalString
(
DataDirFlag
.
Name
)
datadir
:=
MustDataDir
(
ctx
)
cache
:=
ctx
.
GlobalInt
(
CacheFlag
.
Name
)
var
err
error
...
...
@@ -539,11 +539,21 @@ func MakeChain(ctx *cli.Context) (chain *core.ChainManager, chainDb ethdb.Databa
// MakeChain creates an account manager from set command line flags.
func
MakeAccountManager
(
ctx
*
cli
.
Context
)
*
accounts
.
Manager
{
dataDir
:=
ctx
.
GlobalString
(
DataDirFlag
.
Name
)
dataDir
:=
MustDataDir
(
ctx
)
ks
:=
crypto
.
NewKeyStorePassphrase
(
filepath
.
Join
(
dataDir
,
"keystore"
))
return
accounts
.
NewManager
(
ks
)
}
// MustDataDir retrieves the currently requested data directory, terminating if
// none (or the empty string) is specified.
func
MustDataDir
(
ctx
*
cli
.
Context
)
string
{
if
path
:=
ctx
.
GlobalString
(
DataDirFlag
.
Name
);
path
!=
""
{
return
path
}
Fatalf
(
"Cannot determine default data directory, please set manually (--datadir)"
)
return
""
}
func
IpcSocketPath
(
ctx
*
cli
.
Context
)
(
ipcpath
string
)
{
if
runtime
.
GOOS
==
"windows"
{
ipcpath
=
common
.
DefaultIpcPath
()
...
...
common/path.go
View file @
581c0901
...
...
@@ -100,14 +100,24 @@ func DefaultAssetPath() string {
}
func
DefaultDataDir
()
string
{
usr
,
_
:=
user
.
Current
()
if
runtime
.
GOOS
==
"darwin"
{
return
filepath
.
Join
(
usr
.
HomeDir
,
"Library"
,
"Ethereum"
)
}
else
if
runtime
.
GOOS
==
"windows"
{
return
filepath
.
Join
(
usr
.
HomeDir
,
"AppData"
,
"Roaming"
,
"Ethereum"
)
// Try to place the data folder in the user's home dir
var
home
string
if
usr
,
err
:=
user
.
Current
();
err
==
nil
{
home
=
usr
.
HomeDir
}
else
{
return
filepath
.
Join
(
usr
.
HomeDir
,
".ethereum
"
)
home
=
os
.
Getenv
(
"HOME
"
)
}
if
home
!=
""
{
if
runtime
.
GOOS
==
"darwin"
{
return
filepath
.
Join
(
home
,
"Library"
,
"Ethereum"
)
}
else
if
runtime
.
GOOS
==
"windows"
{
return
filepath
.
Join
(
home
,
"AppData"
,
"Roaming"
,
"Ethereum"
)
}
else
{
return
filepath
.
Join
(
home
,
".ethereum"
)
}
}
// As we cannot guess a stable location, return empty and handle later
return
""
}
func
DefaultIpcPath
()
string
{
...
...
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