aboutsummaryrefslogtreecommitdiffstats
path: root/ethchain/vm.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-06-17 17:06:06 +0800
committerobscuren <geffobscura@gmail.com>2014-06-17 17:06:06 +0800
commit53e30f750dd0c91279bfebe01bb12fd170cb74ff (patch)
treeb14fcd5845ce21c774ae7730bdd1d42f8836e5a2 /ethchain/vm.go
parent6656f99c54aef4aaf03ba76dcab3df1cc363ab9a (diff)
downloadgo-tangerine-53e30f750dd0c91279bfebe01bb12fd170cb74ff.tar.gz
go-tangerine-53e30f750dd0c91279bfebe01bb12fd170cb74ff.tar.zst
go-tangerine-53e30f750dd0c91279bfebe01bb12fd170cb74ff.zip
Removal of manual updating of state objects
* You'll only ever need to update the state by calling Update. Update will take care of the updating of it's child state objects.
Diffstat (limited to 'ethchain/vm.go')
-rw-r--r--ethchain/vm.go19
1 files changed, 7 insertions, 12 deletions
diff --git a/ethchain/vm.go b/ethchain/vm.go
index 2ba0e2ef3..77a08faa6 100644
--- a/ethchain/vm.go
+++ b/ethchain/vm.go
@@ -95,9 +95,7 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
step := 0
prevStep := 0
- if ethutil.Config.Debug {
- ethutil.Config.Log.Debugf("# op\n")
- }
+ ethutil.Config.Log.Debugf("# op\n")
for {
prevStep = step
@@ -109,9 +107,8 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
val := closure.Get(pc)
// Get the opcode (it must be an opcode!)
op := OpCode(val.Uint())
- if ethutil.Config.Debug {
- ethutil.Config.Log.Debugf("%-3d %-4s", pc, op.String())
- }
+
+ ethutil.Config.Log.Debugf("%-3d %-4s", pc, op.String())
gas := new(big.Int)
addStepGasUsage := func(amount *big.Int) {
@@ -525,8 +522,6 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
vm.state.Revert(snapshot)
} else {
stack.Push(ethutil.BigD(addr))
-
- vm.state.UpdateStateObject(contract)
}
case CALL:
// TODO RE-WRITE
@@ -569,8 +564,6 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
} else {
stack.Push(ethutil.BigTrue)
- vm.state.UpdateStateObject(contract)
-
mem.Set(retOffset.Int64(), retSize.Int64(), ret)
}
} else {
@@ -589,9 +582,11 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
receiver := vm.state.GetAccount(stack.Pop().Bytes())
receiver.AddAmount(closure.object.Amount)
- vm.state.UpdateStateObject(receiver)
- closure.object.state.Purge()
+ trie := closure.object.state.trie
+ trie.NewIterator().Each(func(key string, v *ethutil.Value) {
+ trie.Delete(key)
+ })
fallthrough
case STOP: // Stop the closure