aboutsummaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'cmd')
-rw-r--r--cmd/ethereum/admin.go5
-rw-r--r--cmd/utils/cmd.go7
2 files changed, 4 insertions, 8 deletions
diff --git a/cmd/ethereum/admin.go b/cmd/ethereum/admin.go
index 967af2553..41aaf46d8 100644
--- a/cmd/ethereum/admin.go
+++ b/cmd/ethereum/admin.go
@@ -221,13 +221,10 @@ func (js *jsre) exportChain(call otto.FunctionCall) otto.Value {
fmt.Println(err)
return otto.FalseValue()
}
-
- data := js.ethereum.ChainManager().Export()
- if err := common.WriteFile(fn, data); err != nil {
+ if err := utils.ExportChain(js.ethereum.ChainManager(), fn); err != nil {
fmt.Println(err)
return otto.FalseValue()
}
-
return otto.TrueValue()
}
diff --git a/cmd/utils/cmd.go b/cmd/utils/cmd.go
index 66e89abef..feea29d64 100644
--- a/cmd/utils/cmd.go
+++ b/cmd/utils/cmd.go
@@ -158,13 +158,12 @@ func ImportChain(chainmgr *core.ChainManager, fn string) error {
var i int
for ; ; i++ {
var b types.Block
- err := stream.Decode(&b)
- if err == io.EOF {
+ if err := stream.Decode(&b); err == io.EOF {
break
} else if err != nil {
return fmt.Errorf("at block %d: %v", i, err)
}
- if err := chainmgr.InsertChain(types.Blocks{b}); err != nil {
+ if err := chainmgr.InsertChain(types.Blocks{&b}); err != nil {
return fmt.Errorf("invalid block %d: %v", i, err)
}
}
@@ -174,7 +173,7 @@ func ImportChain(chainmgr *core.ChainManager, fn string) error {
func ExportChain(chainmgr *core.ChainManager, fn string) error {
fmt.Printf("exporting blockchain '%s'\n", fn)
- fh, err := os.OpenFile(fn, os.O_WRONLY|os.O_TRUNC, os.ModePerm)
+ fh, err := os.OpenFile(fn, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, os.ModePerm)
if err != nil {
return err
}