diff options
Diffstat (limited to 'cmd/geth/main.go')
-rw-r--r-- | cmd/geth/main.go | 50 |
1 files changed, 41 insertions, 9 deletions
diff --git a/cmd/geth/main.go b/cmd/geth/main.go index ef007051c..f2497ccf4 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -23,14 +23,16 @@ package main import ( "bufio" "fmt" + "io" "io/ioutil" "os" + "path" + "path/filepath" "runtime" "strconv" + "strings" "time" - "path" - "github.com/codegangsta/cli" "github.com/ethereum/ethash" "github.com/ethereum/go-ethereum/accounts" @@ -41,13 +43,15 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/eth" "github.com/ethereum/go-ethereum/logger" + "github.com/mattn/go-colorable" + "github.com/mattn/go-isatty" "github.com/peterh/liner" ) import _ "net/http/pprof" const ( ClientIdentifier = "Geth" - Version = "0.9.14" + Version = "0.9.15" ) var ( @@ -301,6 +305,14 @@ func run(ctx *cli.Context) { } func console(ctx *cli.Context) { + // Wrap the standard output with a colorified stream (windows) + if isatty.IsTerminal(os.Stdout.Fd()) { + if pr, pw, err := os.Pipe(); err == nil { + go io.Copy(colorable.NewColorableStdout(), pr) + os.Stdout = pw + } + } + cfg := utils.MakeEthConfig(ClientIdentifier, nodeNameVersion, ctx) ethereum, err := eth.New(cfg) if err != nil { @@ -591,12 +603,32 @@ func dump(ctx *cli.Context) { } func makedag(ctx *cli.Context) { - chain, _, _ := utils.GetChain(ctx) - pow := ethash.New(chain) - fmt.Println("making cache") - pow.UpdateCache(0, true) - fmt.Println("making DAG") - pow.UpdateDAG() + args := ctx.Args() + wrongArgs := func() { + utils.Fatalf(`Usage: geth makedag <block number> <outputdir>`) + } + switch { + case len(args) == 2: + blockNum, err := strconv.ParseUint(args[0], 0, 64) + dir := args[1] + if err != nil { + wrongArgs() + } else { + dir = filepath.Clean(dir) + // seems to require a trailing slash + if !strings.HasSuffix(dir, "/") { + dir = dir + "/" + } + _, err = ioutil.ReadDir(dir) + if err != nil { + utils.Fatalf("Can't find dir") + } + fmt.Println("making DAG, this could take awhile...") + ethash.MakeDAG(blockNum, dir) + } + default: + wrongArgs() + } } func version(c *cli.Context) { |