@ -54,10 +54,11 @@ func importChain(ctx *cli.Context) {
}
}
chain , blockDB , stateDB , extraDB := utils . MakeChain ( ctx )
chain , blockDB , stateDB , extraDB := utils . MakeChain ( ctx )
start := time . Now ( )
start := time . Now ( )
if err := utils . ImportChain ( chain , ctx . Args ( ) . First ( ) ) ; err != nil {
err := utils . ImportChain ( chain , ctx . Args ( ) . First ( ) )
utils . Fatalf ( "Import error: %v\n" , err )
}
flushAll ( blockDB , stateDB , extraDB )
flushAll ( blockDB , stateDB , extraDB )
if err != nil {
utils . Fatalf ( "Import error: %v" , err )
}
fmt . Printf ( "Import done in %v" , time . Since ( start ) )
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" ) )
filename := fmt . Sprintf ( "blockchain_%d_%s.chain" , bcVersion , time . Now ( ) . Format ( "20060102_150405" ) )
exportFile := filepath . Join ( ctx . GlobalString ( utils . DataDirFlag . Name ) , filename )
exportFile := filepath . Join ( ctx . GlobalString ( utils . DataDirFlag . Name ) , filename )
if err := utils . ExportChain ( chain , exportFile ) ; err != nil {
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 )
flushAll ( blockDB , stateDB , extraDB )
os . RemoveAll ( filepath . Join ( ctx . GlobalString ( utils . DataDirFlag . Name ) , "blockchain" ) )
os . RemoveAll ( filepath . Join ( ctx . GlobalString ( utils . DataDirFlag . Name ) , "blockchain" ) )
@ -118,7 +119,7 @@ func upgradeDB(ctx *cli.Context) {
err := utils . ImportChain ( chain , exportFile )
err := utils . ImportChain ( chain , exportFile )
flushAll ( blockDB , stateDB , extraDB )
flushAll ( blockDB , stateDB , extraDB )
if err != nil {
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 {
} else {
os . Remove ( exportFile )
os . Remove ( exportFile )
glog . Infoln ( "Import finished" )
glog . Infoln ( "Import finished" )