From 5553e5aaed5c3f4e303b7d6671d2c92a45aa487e Mon Sep 17 00:00:00 2001 From: obscuren Date: Wed, 10 Dec 2014 19:59:12 +0100 Subject: states moved to chain --- javascript/javascript_runtime.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'javascript') diff --git a/javascript/javascript_runtime.go b/javascript/javascript_runtime.go index a5b929a34..84d61d405 100644 --- a/javascript/javascript_runtime.go +++ b/javascript/javascript_runtime.go @@ -150,7 +150,7 @@ func (self *JSRE) dump(call otto.FunctionCall) otto.Value { state = block.State() } else { - state = self.ethereum.BlockManager().CurrentState() + state = self.ethereum.ChainManager().State() } v, _ := self.Vm.ToValue(state.Dump()) -- cgit v1.2.3 From b1c58b76a9588a90db5a773a997bb70265c378d3 Mon Sep 17 00:00:00 2001 From: obscuren Date: Wed, 17 Dec 2014 12:57:35 +0100 Subject: moved err check --- javascript/javascript_runtime.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'javascript') 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() +} -- cgit v1.2.3