recursive fn in place

This commit is contained in:
Dustin Brickwood 2018-07-11 19:48:06 -04:00
parent fbf3fa25c7
commit efbb2a7a87
3 changed files with 26 additions and 36 deletions

View file

@ -177,9 +177,6 @@ func SwriteTransactions(sqldb *sql.DB, tx *types.Transaction, blockHash common.H
IShyftTracer.GetTracerToRun(hash)
//var stack *node.Node
//var cfg *eth.Config
from := txData.From.Hex()
blockHasher := txData.BlockHash
amount := txData.Amount.String()

View file

@ -533,19 +533,10 @@ func (api *PrivateDebugAPI) computeStateDB(block *types.Block, reexec uint64) (*
// and returns them as a JSON object.
func (api *PrivateDebugAPI) TraceTransaction(ctx context.Context, hash common.Hash, config *TraceConfig) (interface{}, error) {
// NOTE:SHYFT
//fmt.Printf("\n\t[API_TRACER.GO api.config] %+v", api.config)
//fmt.Printf("\n\t[API_TRACER.GO api.eth] %+v\n", api.eth)
// Retrieve the transaction and assemble its EVM context
//fmt.Println("IN TRACE TRANSACTION the chaindb is ")
//fmt.Println(chaindb)
//fmt.Println("IN TRACE TRANSACTION the common hash is ")
//fmt.Println(hash)
tx, blockHash, _, index := core.GetTransaction(api.eth.ChainDb(), hash)
if tx == nil {
return nil, fmt.Errorf("transaction %x not found", hash)
}
reexec := defaultTraceReexec
if config != nil && config.Reexec != nil {
reexec = *config.Reexec
@ -569,10 +560,11 @@ func (api *PrivateDebugAPI) traceTx(ctx context.Context, message core.Message, v
switch {
case config != nil && config.Tracer != nil:
// Define a meaningful timeout of a single transaction trace
timeout := defaultTraceTimeout
fmt.Println(timeout)
_ = defaultTraceTimeout
if config.Timeout != nil {
if timeout, err = time.ParseDuration(*config.Timeout); err != nil {
if _, err = time.ParseDuration(*config.Timeout); err != nil {
return nil, err
}
}
@ -580,6 +572,7 @@ func (api *PrivateDebugAPI) traceTx(ctx context.Context, message core.Message, v
if tracer, err = tracers.New(*config.Tracer); err != nil {
return nil, err
}
// NOTE:SHYFT REMOVED CTX DEADLINE
// Handle timeouts and RPC cancellations
//deadlineCtx, cancel := context.WithTimeout(ctx, timeout)
//go func() {

View file

@ -579,9 +579,29 @@ type Internals struct {
From string
To string
Value string
Gas string
GasUsed string
Calls []*Internals
}
func (i *Internals) InternalRecursive() {
fmt.Println("[Internal To]", i.To)
fmt.Println("[Internal From]", i.From)
lengthOfCalls := len(i.Calls)
fmt.Println("[LENGTH OF CALLS]", lengthOfCalls)
if lengthOfCalls == 0 {
return
}
for _, val := range i.Calls {
val.InternalRecursive()
}
}
// GetResult calls the Javascript 'result' function and returns its value, or any accumulated error
func (jst *Tracer) GetResult() (json.RawMessage, error) {
// Transform the context into a JavaScript object and inject into the state
@ -622,33 +642,13 @@ func (jst *Tracer) GetResult() (json.RawMessage, error) {
jst.vm.DestroyHeap()
jst.vm.Destroy()
//var dat map[string]interface{}
var dat Internals
if err := json.Unmarshal(result, &dat); err != nil {
panic(err)
}
//fmt.Println("[FULL DATA]", string(result))
//fmt.Println("\n +++++++++++++++++++")
//fmt.Println(dat["calls"])
//fmt.Println(dat["calls"]["gasUsed"])
//j, _ := json.Marshal(result)
//internals := string(j)
//fmt.Println("[RESULT]", dat)
//fmt.Println("[RESULT]", dat.To)
//fmt.Println("[Internal Call]", len(dat.Calls))
for key, val := range dat.Calls {
fmt.Println(key)
fmt.Println("[INTERNAL TO]", val.To)
fmt.Println("[INTERNAL From]", val.From)
fmt.Println("[INTERNAL Calls length]", len(val.Calls))
for newKey, newVal := range val.Calls {
fmt.Println(newKey)
fmt.Println("[INSIDE INTERNAL TO]", newVal.To)
}
}
dat.InternalRecursive()
return result, jst.err
}