moved err check
This commit is contained in:
@ -121,6 +121,7 @@ func (self *JSRE) initStdFuncs() {
|
||||
eth.Set("startMining", self.startMining)
|
||||
eth.Set("execBlock", self.execBlock)
|
||||
eth.Set("dump", self.dump)
|
||||
eth.Set("export", self.export)
|
||||
}
|
||||
|
||||
/*
|
||||
@ -236,3 +237,20 @@ func (self *JSRE) execBlock(call otto.FunctionCall) otto.Value {
|
||||
|
||||
return otto.TrueValue()
|
||||
}
|
||||
|
||||
func (self *JSRE) export(call otto.FunctionCall) otto.Value {
|
||||
fn, err := call.Argument(0).ToString()
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return otto.FalseValue()
|
||||
}
|
||||
|
||||
data := self.ethereum.ChainManager().Export()
|
||||
|
||||
if err := ethutil.WriteFile(fn, data); err != nil {
|
||||
fmt.Println(err)
|
||||
return otto.FalseValue()
|
||||
}
|
||||
|
||||
return otto.TrueValue()
|
||||
}
|
||||
|
Reference in New Issue
Block a user