diff options
Diffstat (limited to 'ethereum')
-rw-r--r-- | ethereum/javascript_runtime.go | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/ethereum/javascript_runtime.go b/ethereum/javascript_runtime.go index 34b805e7f..ac05be69b 100644 --- a/ethereum/javascript_runtime.go +++ b/ethereum/javascript_runtime.go @@ -1,4 +1,4 @@ -package main + package main import ( "fmt" @@ -144,6 +144,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) } /* @@ -213,3 +214,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() +} |