diff options
author | Taylor Gerring <taylor.gerring@gmail.com> | 2015-06-06 12:02:32 +0800 |
---|---|---|
committer | Taylor Gerring <taylor.gerring@gmail.com> | 2015-06-06 12:02:32 +0800 |
commit | d65b64c8846636d3e58c1857eaff149d2f82a283 (patch) | |
tree | 3413f344f5a008750e841c2bb4abab5d92e31b0f /cmd/geth | |
parent | 89c9320d8000845ee144f12adee958a5ab2303ef (diff) | |
download | dexon-d65b64c8846636d3e58c1857eaff149d2f82a283.tar dexon-d65b64c8846636d3e58c1857eaff149d2f82a283.tar.gz dexon-d65b64c8846636d3e58c1857eaff149d2f82a283.tar.bz2 dexon-d65b64c8846636d3e58c1857eaff149d2f82a283.tar.lz dexon-d65b64c8846636d3e58c1857eaff149d2f82a283.tar.xz dexon-d65b64c8846636d3e58c1857eaff149d2f82a283.tar.zst dexon-d65b64c8846636d3e58c1857eaff149d2f82a283.zip |
Allow export command to take first and last args
Diffstat (limited to 'cmd/geth')
-rw-r--r-- | cmd/geth/chaincmd.go | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/cmd/geth/chaincmd.go b/cmd/geth/chaincmd.go index 947532f40..509356a90 100644 --- a/cmd/geth/chaincmd.go +++ b/cmd/geth/chaincmd.go @@ -26,6 +26,12 @@ var ( Action: exportChain, Name: "export", Usage: `export blockchain into file`, + Description: ` +Requires a first argument of the file to write to. +Optional second and third arguments control the first and +last block to write. In this mode, the file will be appended +if already existing. + `, } upgradedbCommand = cli.Command{ Action: upgradeDB, @@ -68,7 +74,21 @@ func exportChain(ctx *cli.Context) { } chain, _, _, _ := utils.MakeChain(ctx) start := time.Now() - if err := utils.ExportChain(chain, ctx.Args().First()); err != nil { + + var err error + if len(ctx.Args()) < 3 { + err = utils.ExportChain(chain, ctx.Args().First()) + } else { + // This can be improved to allow for numbers larger than 9223372036854775807 + first, ferr := strconv.ParseInt(ctx.Args().Get(1), 10, 64) + last, lerr := strconv.ParseInt(ctx.Args().Get(2), 10, 64) + if ferr != nil || lerr != nil { + utils.Fatalf("Export error in parsing parameters\n") + } + err = utils.ExportAppendChain(chain, ctx.Args().First(), uint64(first), uint64(last)) + } + + if err != nil { utils.Fatalf("Export error: %v\n", err) } fmt.Printf("Export done in %v", time.Since(start)) |