aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/utils/cmd.go
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2015-03-18 21:04:19 +0800
committerFelix Lange <fjl@twurst.com>2015-03-18 21:04:44 +0800
commit064279c0ec2f048cbdd965c095ea332bb8666f94 (patch)
tree4cd33a264eb0825080eef7aa718580b5092ca887 /cmd/utils/cmd.go
parentd15f90645d5b2e90c441140972d9fe6ecd753643 (diff)
downloaddexon-064279c0ec2f048cbdd965c095ea332bb8666f94.tar
dexon-064279c0ec2f048cbdd965c095ea332bb8666f94.tar.gz
dexon-064279c0ec2f048cbdd965c095ea332bb8666f94.tar.bz2
dexon-064279c0ec2f048cbdd965c095ea332bb8666f94.tar.lz
dexon-064279c0ec2f048cbdd965c095ea332bb8666f94.tar.xz
dexon-064279c0ec2f048cbdd965c095ea332bb8666f94.tar.zst
dexon-064279c0ec2f048cbdd965c095ea332bb8666f94.zip
cmd/ethereum, cmd/utils: partial fix for chain import
Diffstat (limited to 'cmd/utils/cmd.go')
-rw-r--r--cmd/utils/cmd.go7
1 files changed, 3 insertions, 4 deletions
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
}