aboutsummaryrefslogtreecommitdiffstats
path: root/javascript/javascript_runtime.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-12-17 19:57:35 +0800
committerobscuren <geffobscura@gmail.com>2014-12-17 19:57:35 +0800
commitb1c58b76a9588a90db5a773a997bb70265c378d3 (patch)
tree0d2631ec0b9324f08fcd2e82cec797fab75e9d4d /javascript/javascript_runtime.go
parentef4135eabe5cb25f8972371c5681e1611ce0cde9 (diff)
downloadgo-tangerine-b1c58b76a9588a90db5a773a997bb70265c378d3.tar.gz
go-tangerine-b1c58b76a9588a90db5a773a997bb70265c378d3.tar.zst
go-tangerine-b1c58b76a9588a90db5a773a997bb70265c378d3.zip
moved err check
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 84d61d405..a26f0154e 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()
+}