diff options
author | obscuren <geffobscura@gmail.com> | 2014-09-23 01:33:24 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-09-23 01:33:24 +0800 |
commit | 154ca03228a9d97a4b2319f525814a16f102430f (patch) | |
tree | a6e71cdafb18f011c2472d4792075173c132bee6 /utils | |
parent | 7855a233a7ed4968d93fc76a74501c931574f6eb (diff) | |
parent | c7d666ad61a76e79867c9f7ae783a2cc44485dd0 (diff) | |
download | dexon-154ca03228a9d97a4b2319f525814a16f102430f.tar dexon-154ca03228a9d97a4b2319f525814a16f102430f.tar.gz dexon-154ca03228a9d97a4b2319f525814a16f102430f.tar.bz2 dexon-154ca03228a9d97a4b2319f525814a16f102430f.tar.lz dexon-154ca03228a9d97a4b2319f525814a16f102430f.tar.xz dexon-154ca03228a9d97a4b2319f525814a16f102430f.tar.zst dexon-154ca03228a9d97a4b2319f525814a16f102430f.zip |
Merge branch 'release/0.6.5'
Diffstat (limited to 'utils')
-rw-r--r-- | utils/cmd.go | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/utils/cmd.go b/utils/cmd.go index cda735c27..700542cae 100644 --- a/utils/cmd.go +++ b/utils/cmd.go @@ -80,6 +80,16 @@ func confirm(message string) bool { return r == "y" } +func DBSanityCheck(db ethutil.Database) error { + d, _ := db.Get([]byte("ProtocolVersion")) + protov := ethutil.NewValue(d).Uint() + if protov != eth.ProtocolVersion && protov != 0 { + return fmt.Errorf("Database version mismatch. Protocol(%d / %d). `rm -rf %s`", protov, eth.ProtocolVersion, ethutil.Config.ExecPath+"/database") + } + + return nil +} + func InitDataDir(Datadir string) { _, err := os.Stat(Datadir) if err != nil { @@ -90,18 +100,22 @@ func InitDataDir(Datadir string) { } } -func InitLogging(Datadir string, LogFile string, LogLevel int, DebugFile string) { +func InitLogging(Datadir string, LogFile string, LogLevel int, DebugFile string) ethlog.LogSystem { var writer io.Writer if LogFile == "" { writer = os.Stdout } else { writer = openLogFile(Datadir, LogFile) } - ethlog.AddLogSystem(ethlog.NewStdLogSystem(writer, log.LstdFlags, ethlog.LogLevel(LogLevel))) + + sys := ethlog.NewStdLogSystem(writer, log.LstdFlags, ethlog.LogLevel(LogLevel)) + ethlog.AddLogSystem(sys) if DebugFile != "" { writer = openLogFile(Datadir, DebugFile) ethlog.AddLogSystem(ethlog.NewStdLogSystem(writer, log.LstdFlags, ethlog.DebugLevel)) } + + return sys } func InitConfig(ConfigFile string, Datadir string, EnvPrefix string) *ethutil.ConfigManager { @@ -112,7 +126,6 @@ func InitConfig(ConfigFile string, Datadir string, EnvPrefix string) *ethutil.Co func exit(err error) { status := 0 if err != nil { - fmt.Println(err) logger.Errorln("Fatal: ", err) status = 1 } @@ -176,7 +189,7 @@ func DefaultAssetPath() string { // 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", "ethereal") { + if pwd == path.Join(os.Getenv("GOPATH"), "src", "github.com", "ethereum", "go-ethereum", "mist") { assetPath = path.Join(pwd, "assets") } else { switch runtime.GOOS { @@ -185,7 +198,7 @@ func DefaultAssetPath() string { exedir, _ := osext.ExecutableFolder() assetPath = filepath.Join(exedir, "../Resources") case "linux": - assetPath = "/usr/share/ethereal" + assetPath = "/usr/share/mist" case "windows": assetPath = "./assets" default: |