aboutsummaryrefslogtreecommitdiffstats
path: root/javascript
diff options
context:
space:
mode:
Diffstat (limited to 'javascript')
-rw-r--r--javascript/javascript_runtime.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/javascript/javascript_runtime.go b/javascript/javascript_runtime.go
index 169ed509e..af1405049 100644
--- a/javascript/javascript_runtime.go
+++ b/javascript/javascript_runtime.go
@@ -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()
+}