aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/geth/chaincmd.go
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2015-05-27 22:02:08 +0800
committerFelix Lange <fjl@twurst.com>2015-05-28 07:09:26 +0800
commit67effb94b6fadac7b207cb5333c91f578326762e (patch)
treef95a40d3213a23b434845ed89a40a110379f6606 /cmd/geth/chaincmd.go
parent705beb4c25f976f6bce40818bd835e235c2babf4 (diff)
downloaddexon-67effb94b6fadac7b207cb5333c91f578326762e.tar
dexon-67effb94b6fadac7b207cb5333c91f578326762e.tar.gz
dexon-67effb94b6fadac7b207cb5333c91f578326762e.tar.bz2
dexon-67effb94b6fadac7b207cb5333c91f578326762e.tar.lz
dexon-67effb94b6fadac7b207cb5333c91f578326762e.tar.xz
dexon-67effb94b6fadac7b207cb5333c91f578326762e.tar.zst
dexon-67effb94b6fadac7b207cb5333c91f578326762e.zip
cmd/geth, cmd/utils: make chain importing interruptible
Interrupting import with Ctrl-C could cause database corruption because the signal wasn't handled. utils.ImportChain now checks for a queued interrupt on every batch.
Diffstat (limited to 'cmd/geth/chaincmd.go')
-rw-r--r--cmd/geth/chaincmd.go11
1 files changed, 6 insertions, 5 deletions
diff --git a/cmd/geth/chaincmd.go b/cmd/geth/chaincmd.go
index 1aed800f6..6245c691b 100644
--- a/cmd/geth/chaincmd.go
+++ b/cmd/geth/chaincmd.go
@@ -54,10 +54,11 @@ func importChain(ctx *cli.Context) {
}
chain, blockDB, stateDB, extraDB := utils.MakeChain(ctx)
start := time.Now()
- if err := utils.ImportChain(chain, ctx.Args().First()); err != nil {
- utils.Fatalf("Import error: %v\n", err)
- }
+ err := utils.ImportChain(chain, ctx.Args().First())
flushAll(blockDB, stateDB, extraDB)
+ if err != nil {
+ utils.Fatalf("Import error: %v", err)
+ }
fmt.Printf("Import done in %v", time.Since(start))
}
@@ -106,7 +107,7 @@ func upgradeDB(ctx *cli.Context) {
filename := fmt.Sprintf("blockchain_%d_%s.chain", bcVersion, time.Now().Format("20060102_150405"))
exportFile := filepath.Join(ctx.GlobalString(utils.DataDirFlag.Name), filename)
if err := utils.ExportChain(chain, exportFile); err != nil {
- utils.Fatalf("Unable to export chain for reimport %s\n", err)
+ utils.Fatalf("Unable to export chain for reimport %s", err)
}
flushAll(blockDB, stateDB, extraDB)
os.RemoveAll(filepath.Join(ctx.GlobalString(utils.DataDirFlag.Name), "blockchain"))
@@ -118,7 +119,7 @@ func upgradeDB(ctx *cli.Context) {
err := utils.ImportChain(chain, exportFile)
flushAll(blockDB, stateDB, extraDB)
if err != nil {
- utils.Fatalf("Import error %v (a backup is made in %s, use the import command to import it)\n", err, exportFile)
+ utils.Fatalf("Import error %v (a backup is made in %s, use the import command to import it)", err, exportFile)
} else {
os.Remove(exportFile)
glog.Infoln("Import finished")