diff options
author | obscuren <geffobscura@gmail.com> | 2014-07-02 07:04:21 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-07-02 07:04:21 +0800 |
commit | d15952c867f5c31fa68600754bd17c76a992a70e (patch) | |
tree | ed98e63739e9cc60e11a37dc9291de653297803a /ethchain | |
parent | 1954ef47e67762f0308544e3a17976e4c3927e32 (diff) | |
download | dexon-d15952c867f5c31fa68600754bd17c76a992a70e.tar.gz dexon-d15952c867f5c31fa68600754bd17c76a992a70e.tar.zst dexon-d15952c867f5c31fa68600754bd17c76a992a70e.zip |
Moved debug hook to Vm directly
Diffstat (limited to 'ethchain')
-rw-r--r-- | ethchain/closure.go | 6 | ||||
-rw-r--r-- | ethchain/state_transition.go | 2 | ||||
-rw-r--r-- | ethchain/vm.go | 12 |
3 files changed, 11 insertions, 9 deletions
diff --git a/ethchain/closure.go b/ethchain/closure.go index 966e8254a..cc769de30 100644 --- a/ethchain/closure.go +++ b/ethchain/closure.go @@ -74,12 +74,10 @@ func (c *Closure) Address() []byte { return c.object.Address() } -type DebugHook func(step int, op OpCode, mem *Memory, stack *Stack, stateObject *StateObject) bool - -func (c *Closure) Call(vm *Vm, args []byte, hook DebugHook) ([]byte, *big.Int, error) { +func (c *Closure) Call(vm *Vm, args []byte) ([]byte, *big.Int, error) { c.Args = args - ret, err := vm.RunClosure(c, hook) + ret, err := vm.RunClosure(c) return ret, c.UsedGas, err } diff --git a/ethchain/state_transition.go b/ethchain/state_transition.go index c382bcd60..9e7ef3efd 100644 --- a/ethchain/state_transition.go +++ b/ethchain/state_transition.go @@ -261,7 +261,7 @@ func (self *StateTransition) Eval(script []byte, context *StateObject) (ret []by } func Call(vm *Vm, closure *Closure, data []byte) (ret []byte, err error, deepErr bool) { - ret, _, err = closure.Call(vm, data, nil) + ret, _, err = closure.Call(vm, data) deepErr = vm.err != nil Paranoia := ethutil.Config.Paranoia diff --git a/ethchain/vm.go b/ethchain/vm.go index 0b8799a12..7acca9b36 100644 --- a/ethchain/vm.go +++ b/ethchain/vm.go @@ -52,8 +52,12 @@ type Vm struct { logStr string err error + + Hook DebugHook } +type DebugHook func(step int, op OpCode, mem *Memory, stack *Stack, stateObject *StateObject) bool + type RuntimeVars struct { Origin []byte Block *Block @@ -91,7 +95,7 @@ var Pow256 = ethutil.BigPow(2, 256) var isRequireError = false -func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err error) { +func (vm *Vm) RunClosure(closure *Closure) (ret []byte, err error) { // Recover from any require exception defer func() { if r := recover(); r != nil { @@ -642,7 +646,7 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro // Call the closure and set the return value as // main script. var err error - c.Script, gas, err = c.Call(vm, nil, hook) + c.Script, gas, err = c.Call(vm, nil) if err != nil { stack.Push(ethutil.BigFalse) @@ -738,8 +742,8 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro vm.Endl() - if hook != nil { - if !hook(prevStep, op, mem, stack, closure.Object()) { + if vm.Hook != nil { + if !vm.Hook(prevStep, op, mem, stack, closure.Object()) { return nil, nil } } |