aboutsummaryrefslogtreecommitdiffstats
path: root/ethchain/vm.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-04-11 20:28:30 +0800
committerobscuren <geffobscura@gmail.com>2014-04-11 20:28:30 +0800
commitca747f268800590ee855b1ce593b61e95d073311 (patch)
tree22c5aa975cec4835923a9ac752c1d243108c0c8f /ethchain/vm.go
parent7d6ba88d2b4a263f2a898c3ef6d40e5258f96bb0 (diff)
downloadgo-tangerine-ca747f268800590ee855b1ce593b61e95d073311.tar
go-tangerine-ca747f268800590ee855b1ce593b61e95d073311.tar.gz
go-tangerine-ca747f268800590ee855b1ce593b61e95d073311.tar.bz2
go-tangerine-ca747f268800590ee855b1ce593b61e95d073311.tar.lz
go-tangerine-ca747f268800590ee855b1ce593b61e95d073311.tar.xz
go-tangerine-ca747f268800590ee855b1ce593b61e95d073311.tar.zst
go-tangerine-ca747f268800590ee855b1ce593b61e95d073311.zip
Added the possibility for debug hooks during closure call
Diffstat (limited to 'ethchain/vm.go')
-rw-r--r--ethchain/vm.go45
1 files changed, 5 insertions, 40 deletions
diff --git a/ethchain/vm.go b/ethchain/vm.go
index dd99ee790..dce972cc7 100644
--- a/ethchain/vm.go
+++ b/ethchain/vm.go
@@ -48,7 +48,7 @@ func NewVm(state *State, vars RuntimeVars) *Vm {
var Pow256 = ethutil.BigPow(2, 256)
-func (vm *Vm) RunClosure(closure *Closure) []byte {
+func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) []byte {
// If the amount of gas supplied is less equal to 0
if closure.Gas.Cmp(big.NewInt(0)) <= 0 {
// TODO Do something
@@ -372,7 +372,7 @@ func (vm *Vm) RunClosure(closure *Closure) []byte {
// Create a new callable closure
closure := NewClosure(closure, contract, contract.script, vm.state, gas, value)
// Executer the closure and get the return value (if any)
- ret := closure.Call(vm, args)
+ ret := closure.Call(vm, args, hook)
mem.Set(retOffset.Int64(), retSize.Int64(), ret)
case oRETURN:
@@ -404,44 +404,9 @@ func (vm *Vm) RunClosure(closure *Closure) []byte {
}
pc.Add(pc, ethutil.Big1)
- }
-}
-
-/*
-func makeInlineTx(addr []byte, value, from, length *big.Int, contract *Contract, state *State) {
- ethutil.Config.Log.Debugf(" => creating inline tx %x %v %v %v", addr, value, from, length)
- j := int64(0)
- dataItems := make([]string, int(length.Uint64()))
- for i := from.Int64(); i < length.Int64(); i++ {
- dataItems[j] = contract.GetMem(big.NewInt(j)).Str()
- j++
- }
- tx := NewTransaction(addr, value, dataItems)
- if tx.IsContract() {
- contract := MakeContract(tx, state)
- state.UpdateContract(contract)
- } else {
- account := state.GetAccount(tx.Recipient)
- account.Amount.Add(account.Amount, tx.Value)
- state.UpdateAccount(tx.Recipient, account)
- }
-}
-
-// Returns an address from the specified contract's address
-func contractMemory(state *State, contractAddr []byte, memAddr *big.Int) *big.Int {
- contract := state.GetContract(contractAddr)
- if contract == nil {
- log.Panicf("invalid contract addr %x", contractAddr)
- }
- val := state.trie.Get(memAddr.String())
-
- // decode the object as a big integer
- decoder := ethutil.NewValueFromBytes([]byte(val))
- if decoder.IsNil() {
- return ethutil.BigFalse
+ if hook != nil {
+ hook(op)
+ }
}
-
- return decoder.BigInt()
}
-*/