aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/geth
diff options
context:
space:
mode:
authorJeffrey Wilcke <jeffrey@ethereum.org>2015-06-09 07:32:38 +0800
committerJeffrey Wilcke <jeffrey@ethereum.org>2015-06-09 07:32:38 +0800
commit0f1cdfa53ad445df7bf3aed281fc36e53ecbbfd4 (patch)
tree4acfaeb81842b085838008583800917387e97002 /cmd/geth
parent81ceac1b96bdd61b9f2f80359607e451061fc02f (diff)
parent4ab0cedf42abea8becc5177e566c070730f13a07 (diff)
downloadgo-tangerine-0f1cdfa53ad445df7bf3aed281fc36e53ecbbfd4.tar.gz
go-tangerine-0f1cdfa53ad445df7bf3aed281fc36e53ecbbfd4.tar.zst
go-tangerine-0f1cdfa53ad445df7bf3aed281fc36e53ecbbfd4.zip
Merge pull request #1193 from tgerring/hotbackup
Improve export command
Diffstat (limited to 'cmd/geth')
-rw-r--r--cmd/geth/chaincmd.go28
1 files changed, 26 insertions, 2 deletions
diff --git a/cmd/geth/chaincmd.go b/cmd/geth/chaincmd.go
index 947532f40..8586e3b81 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,
@@ -63,12 +69,30 @@ func importChain(ctx *cli.Context) {
}
func exportChain(ctx *cli.Context) {
- if len(ctx.Args()) != 1 {
+ if len(ctx.Args()) < 1 {
utils.Fatalf("This command requires an argument.")
}
chain, _, _, _ := utils.MakeChain(ctx)
start := time.Now()
- if err := utils.ExportChain(chain, ctx.Args().First()); err != nil {
+
+ var err error
+ fp := ctx.Args().First()
+ if len(ctx.Args()) < 3 {
+ err = utils.ExportChain(chain, fp)
+ } 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: block number not an integer\n")
+ }
+ if first < 0 || last < 0 {
+ utils.Fatalf("Export error: block number must be greater than 0\n")
+ }
+ err = utils.ExportAppendChain(chain, fp, uint64(first), uint64(last))
+ }
+
+ if err != nil {
utils.Fatalf("Export error: %v\n", err)
}
fmt.Printf("Export done in %v", time.Since(start))