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
d5aed82b
Commit
d5aed82b
authored
Feb 26, 2015
by
Taylor Gerring
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DRY DefaultAssetPath()
parent
8eeab7ea
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
54 deletions
+27
-54
flags.go
cmd/mist/flags.go
+1
-28
cmd.go
cmd/utils/cmd.go
+0
-26
common.go
ethutil/common.go
+26
-0
No files found.
cmd/mist/flags.go
View file @
d5aed82b
...
@@ -68,33 +68,6 @@ var (
...
@@ -68,33 +68,6 @@ var (
// flags specific to gui client
// flags specific to gui client
var
AssetPath
string
var
AssetPath
string
//TODO: If we re-use the one defined in cmd.go the binary osx image crashes. If somebody finds out why we can dry this up.
func
defaultAssetPath
()
string
{
var
assetPath
string
// If the current working directory is the go-ethereum dir
// assume a debug build and use the source directory as
// asset directory.
pwd
,
_
:=
os
.
Getwd
()
if
pwd
==
path
.
Join
(
os
.
Getenv
(
"GOPATH"
),
"src"
,
"github.com"
,
"ethereum"
,
"go-ethereum"
,
"cmd"
,
"mist"
)
{
assetPath
=
path
.
Join
(
pwd
,
"assets"
)
}
else
{
switch
runtime
.
GOOS
{
case
"darwin"
:
// Get Binary Directory
exedir
,
_
:=
osext
.
ExecutableFolder
()
assetPath
=
filepath
.
Join
(
exedir
,
"../Resources"
)
case
"linux"
:
assetPath
=
"/usr/share/mist"
case
"windows"
:
assetPath
=
"./assets"
default
:
assetPath
=
"."
}
}
return
assetPath
}
var
defaultConfigFile
=
path
.
Join
(
ethutil
.
DefaultDataDir
(),
"conf.ini"
)
var
defaultConfigFile
=
path
.
Join
(
ethutil
.
DefaultDataDir
(),
"conf.ini"
)
func
Init
()
{
func
Init
()
{
...
@@ -122,7 +95,7 @@ func Init() {
...
@@ -122,7 +95,7 @@ func Init() {
flag
.
StringVar
(
&
DebugFile
,
"debug"
,
""
,
"debug file (no debugging if not set)"
)
flag
.
StringVar
(
&
DebugFile
,
"debug"
,
""
,
"debug file (no debugging if not set)"
)
flag
.
IntVar
(
&
LogLevel
,
"loglevel"
,
int
(
logger
.
InfoLevel
),
"loglevel: 0-5: silent,error,warn,info,debug,debug detail)"
)
flag
.
IntVar
(
&
LogLevel
,
"loglevel"
,
int
(
logger
.
InfoLevel
),
"loglevel: 0-5: silent,error,warn,info,debug,debug detail)"
)
flag
.
StringVar
(
&
AssetPath
,
"asset_path"
,
d
efaultAssetPath
(),
"absolute path to GUI assets directory"
)
flag
.
StringVar
(
&
AssetPath
,
"asset_path"
,
ethutil
.
D
efaultAssetPath
(),
"absolute path to GUI assets directory"
)
// Network stuff
// Network stuff
var
(
var
(
...
...
cmd/utils/cmd.go
View file @
d5aed82b
...
@@ -41,7 +41,6 @@ import (
...
@@ -41,7 +41,6 @@ import (
rpcws
"github.com/ethereum/go-ethereum/rpc/ws"
rpcws
"github.com/ethereum/go-ethereum/rpc/ws"
"github.com/ethereum/go-ethereum/state"
"github.com/ethereum/go-ethereum/state"
"github.com/ethereum/go-ethereum/xeth"
"github.com/ethereum/go-ethereum/xeth"
"github.com/kardianos/osext"
)
)
var
clilogger
=
logger
.
NewLogger
(
"CLI"
)
var
clilogger
=
logger
.
NewLogger
(
"CLI"
)
...
@@ -132,31 +131,6 @@ func StartEthereum(ethereum *eth.Ethereum) {
...
@@ -132,31 +131,6 @@ func StartEthereum(ethereum *eth.Ethereum) {
})
})
}
}
func
DefaultAssetPath
()
string
{
var
assetPath
string
// If the current working directory is the go-ethereum dir
// assume a debug build and use the source directory as
// asset directory.
pwd
,
_
:=
os
.
Getwd
()
if
pwd
==
path
.
Join
(
os
.
Getenv
(
"GOPATH"
),
"src"
,
"github.com"
,
"ethereum"
,
"go-ethereum"
,
"cmd"
,
"mist"
)
{
assetPath
=
path
.
Join
(
pwd
,
"assets"
)
}
else
{
switch
runtime
.
GOOS
{
case
"darwin"
:
// Get Binary Directory
exedir
,
_
:=
osext
.
ExecutableFolder
()
assetPath
=
filepath
.
Join
(
exedir
,
"../Resources"
)
case
"linux"
:
assetPath
=
"/usr/share/mist"
case
"windows"
:
assetPath
=
"./assets"
default
:
assetPath
=
"."
}
}
return
assetPath
}
func
KeyTasks
(
keyManager
*
crypto
.
KeyManager
,
KeyRing
string
,
GenAddr
bool
,
SecretFile
string
,
ExportDir
string
,
NonInteractive
bool
)
{
func
KeyTasks
(
keyManager
*
crypto
.
KeyManager
,
KeyRing
string
,
GenAddr
bool
,
SecretFile
string
,
ExportDir
string
,
NonInteractive
bool
)
{
var
err
error
var
err
error
...
...
ethutil/common.go
View file @
d5aed82b
...
@@ -2,6 +2,7 @@ package ethutil
...
@@ -2,6 +2,7 @@ package ethutil
import
(
import
(
"fmt"
"fmt"
"github.com/kardianos/osext"
"math/big"
"math/big"
"os/user"
"os/user"
"path"
"path"
...
@@ -9,6 +10,31 @@ import (
...
@@ -9,6 +10,31 @@ import (
"time"
"time"
)
)
func
DefaultAssetPath
()
string
{
var
assetPath
string
// If the current working directory is the go-ethereum dir
// assume a debug build and use the source directory as
// asset directory.
pwd
,
_
:=
os
.
Getwd
()
if
pwd
==
path
.
Join
(
os
.
Getenv
(
"GOPATH"
),
"src"
,
"github.com"
,
"ethereum"
,
"go-ethereum"
,
"cmd"
,
"mist"
)
{
assetPath
=
path
.
Join
(
pwd
,
"assets"
)
}
else
{
switch
runtime
.
GOOS
{
case
"darwin"
:
// Get Binary Directory
exedir
,
_
:=
osext
.
ExecutableFolder
()
assetPath
=
filepath
.
Join
(
exedir
,
"../Resources"
)
case
"linux"
:
assetPath
=
"/usr/share/mist"
case
"windows"
:
assetPath
=
"./assets"
default
:
assetPath
=
"."
}
}
return
assetPath
}
func
DefaultDataDir
()
string
{
func
DefaultDataDir
()
string
{
usr
,
_
:=
user
.
Current
()
usr
,
_
:=
user
.
Current
()
if
runtime
.
GOOS
==
"darwin"
{
if
runtime
.
GOOS
==
"darwin"
{
...
...
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