diff options
author | obscuren <geffobscura@gmail.com> | 2014-05-02 04:14:34 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-05-02 04:14:34 +0800 |
commit | 17674fb888d3dc2de081f1c781a227b61c961189 (patch) | |
tree | 873a8d59a5b34eff3dbf5d64928272477ee668c0 /ethchain/vm.go | |
parent | 91aa189ef31adff7f4a084cae770aaa7c01f11e5 (diff) | |
download | go-tangerine-17674fb888d3dc2de081f1c781a227b61c961189.tar go-tangerine-17674fb888d3dc2de081f1c781a227b61c961189.tar.gz go-tangerine-17674fb888d3dc2de081f1c781a227b61c961189.tar.bz2 go-tangerine-17674fb888d3dc2de081f1c781a227b61c961189.tar.lz go-tangerine-17674fb888d3dc2de081f1c781a227b61c961189.tar.xz go-tangerine-17674fb888d3dc2de081f1c781a227b61c961189.tar.zst go-tangerine-17674fb888d3dc2de081f1c781a227b61c961189.zip |
Added suicide back in
Diffstat (limited to 'ethchain/vm.go')
-rw-r--r-- | ethchain/vm.go | 44 |
1 files changed, 18 insertions, 26 deletions
diff --git a/ethchain/vm.go b/ethchain/vm.go index 0a3690c41..3a3b3447a 100644 --- a/ethchain/vm.go +++ b/ethchain/vm.go @@ -73,10 +73,7 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro } }() - // If the amount of gas supplied is less equal to 0 - if closure.Gas.Cmp(big.NewInt(0)) <= 0 { - // TODO Do something - } + ethutil.Config.Log.Debugf("[VM] Running closure %x\n", closure.object.Address()) // Memory for the current closure mem := &Memory{} @@ -107,9 +104,11 @@ 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()) - } + /* + if ethutil.Config.Debug { + ethutil.Config.Log.Debugf("%-3d %-4s", pc, op.String()) + } + */ gas := new(big.Int) useGas := func(amount *big.Int) { @@ -163,9 +162,6 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro case oLOG: stack.Print() mem.Print() - case oSTOP: // Stop the closure - return closure.Return(nil), nil - // 0x20 range case oADD: require(2) @@ -520,22 +516,18 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro return closure.Return(ret), nil case oSUICIDE: - /* - recAddr := stack.Pop().Bytes() - // Purge all memory - deletedMemory := contract.state.Purge() - // Add refunds to the pop'ed address - refund := new(big.Int).Mul(StoreFee, big.NewInt(int64(deletedMemory))) - account := state.GetAccount(recAddr) - account.Amount.Add(account.Amount, refund) - // Update the refunding address - state.UpdateAccount(recAddr, account) - // Delete the contract - state.trie.Update(string(addr), "") - - ethutil.Config.Log.Debugf("(%d) => %x\n", deletedMemory, recAddr) - break out - */ + require(1) + + receiver := vm.state.GetAccount(stack.Pop().Bytes()) + receiver.AddAmount(closure.object.Amount) + + vm.stateManager.manifest.AddObjectChange(receiver) + + closure.object.state.Purge() + + fallthrough + case oSTOP: // Stop the closure + return closure.Return(nil), nil default: ethutil.Config.Log.Debugf("Invalid opcode %x\n", op) |