File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -221,13 +221,10 @@ func (js *jsre) exportChain(call otto.FunctionCall) otto.Value {
221221 fmt .Println (err )
222222 return otto .FalseValue ()
223223 }
224-
225- data := js .ethereum .ChainManager ().Export ()
226- if err := common .WriteFile (fn , data ); err != nil {
224+ if err := utils .ExportChain (js .ethereum .ChainManager (), fn ); err != nil {
227225 fmt .Println (err )
228226 return otto .FalseValue ()
229227 }
230-
231228 return otto .TrueValue ()
232229}
233230
Original file line number Diff line number Diff line change @@ -158,13 +158,12 @@ func ImportChain(chainmgr *core.ChainManager, fn string) error {
158158 var i int
159159 for ; ; i ++ {
160160 var b types.Block
161- err := stream .Decode (& b )
162- if err == io .EOF {
161+ if err := stream .Decode (& b ); err == io .EOF {
163162 break
164163 } else if err != nil {
165164 return fmt .Errorf ("at block %d: %v" , i , err )
166165 }
167- if err := chainmgr .InsertChain (types.Blocks {b }); err != nil {
166+ if err := chainmgr .InsertChain (types.Blocks {& b }); err != nil {
168167 return fmt .Errorf ("invalid block %d: %v" , i , err )
169168 }
170169 }
@@ -174,7 +173,7 @@ func ImportChain(chainmgr *core.ChainManager, fn string) error {
174173
175174func ExportChain (chainmgr * core.ChainManager , fn string ) error {
176175 fmt .Printf ("exporting blockchain '%s'\n " , fn )
177- fh , err := os .OpenFile (fn , os .O_WRONLY | os .O_TRUNC , os .ModePerm )
176+ fh , err := os .OpenFile (fn , os .O_CREATE | os . O_WRONLY | os .O_TRUNC , os .ModePerm )
178177 if err != nil {
179178 return err
180179 }
You can’t perform that action at this time.
0 commit comments