Merge branch 'develop' into poc8

This commit is contained in:
obscuren
2014-12-18 00:12:51 +01:00
9 changed files with 128 additions and 31 deletions

View File

@ -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()
}