diff options
author | Gustav Simonsson <gustav.simonsson@gmail.com> | 2015-05-05 14:24:15 +0800 |
---|---|---|
committer | Gustav Simonsson <gustav.simonsson@gmail.com> | 2015-05-05 14:24:15 +0800 |
commit | b1cc9cdc7424d452687e2e168027d591ed332f3f (patch) | |
tree | 85f9860c5348f7cce620349977e4dac5ab5140f8 /cmd/geth/main.go | |
parent | 50659f4b480fb9446cfb40955331a7a044353ff8 (diff) | |
download | go-tangerine-b1cc9cdc7424d452687e2e168027d591ed332f3f.tar go-tangerine-b1cc9cdc7424d452687e2e168027d591ed332f3f.tar.gz go-tangerine-b1cc9cdc7424d452687e2e168027d591ed332f3f.tar.bz2 go-tangerine-b1cc9cdc7424d452687e2e168027d591ed332f3f.tar.lz go-tangerine-b1cc9cdc7424d452687e2e168027d591ed332f3f.tar.xz go-tangerine-b1cc9cdc7424d452687e2e168027d591ed332f3f.tar.zst go-tangerine-b1cc9cdc7424d452687e2e168027d591ed332f3f.zip |
Integrate new ethash API and change geth makedag cmd
Diffstat (limited to 'cmd/geth/main.go')
-rw-r--r-- | cmd/geth/main.go | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/cmd/geth/main.go b/cmd/geth/main.go index e00b139c0..f2497ccf4 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -27,8 +27,10 @@ import ( "io/ioutil" "os" "path" + "path/filepath" "runtime" "strconv" + "strings" "time" "github.com/codegangsta/cli" @@ -601,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) { |