From 176b7802510a667b8973f2be232f7a8213b3474b Mon Sep 17 00:00:00 2001 From: obscuren Date: Mon, 23 Jun 2014 11:28:05 +0200 Subject: Added a execBlock method which replays the given block --- ethereum/javascript_runtime.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'ethereum') diff --git a/ethereum/javascript_runtime.go b/ethereum/javascript_runtime.go index b05d39232..737f7663f 100644 --- a/ethereum/javascript_runtime.go +++ b/ethereum/javascript_runtime.go @@ -138,6 +138,7 @@ func (self *JSRE) initStdFuncs() { eth.Set("require", self.require) eth.Set("stopMining", self.stopMining) eth.Set("startMining", self.startMining) + eth.Set("blockDo", self.execBlock) } /* @@ -207,3 +208,18 @@ func (self *JSRE) require(call otto.FunctionCall) otto.Value { return t } + +func (self *JSRE) execBlock(call otto.FunctionCall) otto.Value { + hash, err := call.Argument(0).ToString() + if err != nil { + return otto.UndefinedValue() + } + + err = self.ethereum.BlockDo(ethutil.FromHex(hash)) + if err != nil { + fmt.Println(err) + return otto.FalseValue() + } + + return otto.TrueValue() +} -- cgit