diff options
author | zelig <viktor.tron@gmail.com> | 2015-03-08 23:44:48 +0800 |
---|---|---|
committer | zelig <viktor.tron@gmail.com> | 2015-03-08 23:44:48 +0800 |
commit | 51eed7964ec35bbdc23dd8a4a8fffedad247e33d (patch) | |
tree | fe539264e3a36bedbb016a5e31a3bb838e21c795 /cmd/ethereum | |
parent | 07955b30419a26b9b213f71955a02a49995dc0e3 (diff) | |
download | dexon-51eed7964ec35bbdc23dd8a4a8fffedad247e33d.tar dexon-51eed7964ec35bbdc23dd8a4a8fffedad247e33d.tar.gz dexon-51eed7964ec35bbdc23dd8a4a8fffedad247e33d.tar.bz2 dexon-51eed7964ec35bbdc23dd8a4a8fffedad247e33d.tar.lz dexon-51eed7964ec35bbdc23dd8a4a8fffedad247e33d.tar.xz dexon-51eed7964ec35bbdc23dd8a4a8fffedad247e33d.tar.zst dexon-51eed7964ec35bbdc23dd8a4a8fffedad247e33d.zip |
add export blockchain subcommand, remove BlockDo
Diffstat (limited to 'cmd/ethereum')
-rw-r--r-- | cmd/ethereum/main.go | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/cmd/ethereum/main.go b/cmd/ethereum/main.go index 8b361f7ae..f3f428156 100644 --- a/cmd/ethereum/main.go +++ b/cmd/ethereum/main.go @@ -87,6 +87,11 @@ runtime will execute the file and exit. Name: "import", Usage: `import a blockchain file`, }, + { + Action: exportchain, + Name: "export", + Usage: `export blockchain into file`, + }, } app.Author = "" app.Email = "" @@ -171,25 +176,39 @@ func importchain(ctx *cli.Context) { if len(ctx.Args()) != 1 { utils.Fatalf("This command requires an argument.") } - chain, _, _ := utils.GetChain(ctx) + chainmgr, _, _ := utils.GetChain(ctx) start := time.Now() - err := utils.ImportChain(chain, ctx.Args().First()) + err := utils.ImportChain(chainmgr, ctx.Args().First()) if err != nil { utils.Fatalf("Import error: %v\n", err) } - fmt.Printf("Import done in", time.Since(start)) + fmt.Printf("Import done in %v", time.Since(start)) + return +} + +func exportchain(ctx *cli.Context) { + if len(ctx.Args()) != 1 { + utils.Fatalf("This command requires an argument.") + } + chainmgr, _, _ := utils.GetChain(ctx) + start := time.Now() + err := utils.ExportChain(chainmgr, ctx.Args().First()) + if err != nil { + utils.Fatalf("Export error: %v\n", err) + } + fmt.Printf("Export done in %v", time.Since(start)) return } func dump(ctx *cli.Context) { - chain, _, stateDb := utils.GetChain(ctx) + chainmgr, _, stateDb := utils.GetChain(ctx) for _, arg := range ctx.Args() { var block *types.Block if hashish(arg) { - block = chain.GetBlock(ethutil.Hex2Bytes(arg)) + block = chainmgr.GetBlock(ethutil.Hex2Bytes(arg)) } else { num, _ := strconv.Atoi(arg) - block = chain.GetBlockByNumber(uint64(num)) + block = chainmgr.GetBlockByNumber(uint64(num)) } if block == nil { fmt.Println("{}") |