aboutsummaryrefslogtreecommitdiffstats
path: root/javascript/javascript_runtime.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-12-18 07:12:51 +0800
committerobscuren <geffobscura@gmail.com>2014-12-18 07:12:51 +0800
commite6fdf0c9f7564b8b08cf428e03af66fc423adcc1 (patch)
tree14fafd42083a9a5d57005b614740294ae0525bef /javascript/javascript_runtime.go
parent52b54631a47dfa46742635be178f2f8d33dd9f41 (diff)
parent4dbdcaecb117d7e1fcaf0869f5d4602312552991 (diff)
downloadgo-tangerine-e6fdf0c9f7564b8b08cf428e03af66fc423adcc1.tar.gz
go-tangerine-e6fdf0c9f7564b8b08cf428e03af66fc423adcc1.tar.zst
go-tangerine-e6fdf0c9f7564b8b08cf428e03af66fc423adcc1.zip
Merge branch 'develop' into poc8
Diffstat (limited to 'javascript/javascript_runtime.go')
-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()
+}