Commit 858f17d2 authored by yann300's avatar yann300

change way of bulding the calltree

parent 1e5e4e8f
...@@ -7,9 +7,8 @@ TraceCache.prototype.init = function () { ...@@ -7,9 +7,8 @@ TraceCache.prototype.init = function () {
// ...Changes contains index in the vmtrace of the corresponding changes // ...Changes contains index in the vmtrace of the corresponding changes
this.returnValues = {} this.returnValues = {}
this.callChanges = [] this.currentCall = null
this.calls = {} this.callsTree = null
this.callsRef = [] // track of calls during the vm trace analysis
this.callsData = {} this.callsData = {}
this.contractCreation = {} this.contractCreation = {}
this.steps = {} this.steps = {}
...@@ -35,24 +34,26 @@ TraceCache.prototype.pushMemoryChanges = function (value) { ...@@ -35,24 +34,26 @@ TraceCache.prototype.pushMemoryChanges = function (value) {
} }
TraceCache.prototype.pushCall = function (step, index, address, callStack, outofGas) { TraceCache.prototype.pushCall = function (step, index, address, callStack, outofGas) {
var call = {
op: step.op,
address: address,
callStack: callStack,
outofGas: outofGas
}
if (step.op === 'RETURN' || step.op === 'STOP' || outofGas) { if (step.op === 'RETURN' || step.op === 'STOP' || outofGas) {
if (this.callsRef.length > 1) { // we are returning from an internal call this.currentCall.call.return = index
this.callChanges.push(index) var parent = this.currentCall.parent
this.calls[index] = call this.currentCall = { call: parent.call, parent: parent.parent }
var callIndex = this.callsRef.pop()
this.calls[index].call = callIndex
this.calls[callIndex].return = index
}
} else { } else {
this.callChanges.push(index) var call = {
this.calls[index] = call op: step.op,
this.callsRef.push(index) address: address,
callStack: callStack,
outofGas: outofGas,
calls: {},
start: index
}
this.addresses.push(address)
if (this.currentCall) {
this.currentCall.call.calls[index] = call
} else {
this.callsTree = { call: call }
}
this.currentCall = { call: call, parent: this.currentCall }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment