diff options
author | obscuren <geffobscura@gmail.com> | 2014-06-23 17:28:05 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-06-23 17:28:05 +0800 |
commit | 176b7802510a667b8973f2be232f7a8213b3474b (patch) | |
tree | 69c4a90ee0c6c562d1a85ab30a96511dca0af878 /ethereum/javascript_runtime.go | |
parent | 2408e38218d81c567bdaa4671a542a20c55490b9 (diff) | |
download | dexon-176b7802510a667b8973f2be232f7a8213b3474b.tar dexon-176b7802510a667b8973f2be232f7a8213b3474b.tar.gz dexon-176b7802510a667b8973f2be232f7a8213b3474b.tar.bz2 dexon-176b7802510a667b8973f2be232f7a8213b3474b.tar.lz dexon-176b7802510a667b8973f2be232f7a8213b3474b.tar.xz dexon-176b7802510a667b8973f2be232f7a8213b3474b.tar.zst dexon-176b7802510a667b8973f2be232f7a8213b3474b.zip |
Added a execBlock method which replays the given block
Diffstat (limited to 'ethereum/javascript_runtime.go')
-rw-r--r-- | ethereum/javascript_runtime.go | 16 |
1 files changed, 16 insertions, 0 deletions
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() +} |