Notify of changes

This commit is contained in:
obscuren 2014-04-26 02:06:25 +02:00
parent d3a159ad3d
commit ca6e3f6def
1 changed files with 4 additions and 5 deletions

View File

@ -56,8 +56,6 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
// Recover from any require exception // Recover from any require exception
defer func() { defer func() {
if r := recover(); r != nil /*&& isRequireError*/ { if r := recover(); r != nil /*&& isRequireError*/ {
fmt.Println(r)
ret = closure.Return(nil) ret = closure.Return(nil)
err = fmt.Errorf("%v", r) err = fmt.Errorf("%v", r)
fmt.Println("vm err", err) fmt.Println("vm err", err)
@ -158,7 +156,6 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
x, y := stack.Popn() x, y := stack.Popn()
// (x + y) % 2 ** 256 // (x + y) % 2 ** 256
base.Add(x, y) base.Add(x, y)
fmt.Println(x, y, base)
// Pop result back on the stack // Pop result back on the stack
stack.Push(base) stack.Push(base)
case oSUB: case oSUB:
@ -321,7 +318,6 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
require(1) require(1)
offset := stack.Pop().Int64() offset := stack.Pop().Int64()
val := closure.Args[offset : offset+32] val := closure.Args[offset : offset+32]
fmt.Println(ethutil.BigD(val))
stack.Push(ethutil.BigD(val)) stack.Push(ethutil.BigD(val))
case oCALLDATASIZE: case oCALLDATASIZE:
@ -394,7 +390,6 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
require(1) require(1)
loc := stack.Pop() loc := stack.Pop()
val := closure.GetMem(loc) val := closure.GetMem(loc)
fmt.Printf("load %x = %v\n", loc.Bytes(), val.BigInt())
stack.Push(val.BigInt()) stack.Push(val.BigInt())
case oSSTORE: case oSSTORE:
require(2) require(2)
@ -452,8 +447,12 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
ret, err := closure.Call(vm, args, hook) ret, err := closure.Call(vm, args, hook)
if err != nil { if err != nil {
stack.Push(ethutil.BigFalse) stack.Push(ethutil.BigFalse)
// Reset the changes applied this object
//contract.State().Reset()
} else { } else {
stack.Push(ethutil.BigTrue) stack.Push(ethutil.BigTrue)
// Notify of the changes
vm.stateManager.Changed(contract)
} }
mem.Set(retOffset.Int64(), retSize.Int64(), ret) mem.Set(retOffset.Int64(), retSize.Int64(), ret)