mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 02:12:23 +00:00
recursive fn in place
This commit is contained in:
parent
fbf3fa25c7
commit
efbb2a7a87
3 changed files with 26 additions and 36 deletions
|
|
@ -177,9 +177,6 @@ func SwriteTransactions(sqldb *sql.DB, tx *types.Transaction, blockHash common.H
|
||||||
|
|
||||||
IShyftTracer.GetTracerToRun(hash)
|
IShyftTracer.GetTracerToRun(hash)
|
||||||
|
|
||||||
//var stack *node.Node
|
|
||||||
//var cfg *eth.Config
|
|
||||||
|
|
||||||
from := txData.From.Hex()
|
from := txData.From.Hex()
|
||||||
blockHasher := txData.BlockHash
|
blockHasher := txData.BlockHash
|
||||||
amount := txData.Amount.String()
|
amount := txData.Amount.String()
|
||||||
|
|
|
||||||
|
|
@ -533,19 +533,10 @@ func (api *PrivateDebugAPI) computeStateDB(block *types.Block, reexec uint64) (*
|
||||||
// and returns them as a JSON object.
|
// and returns them as a JSON object.
|
||||||
func (api *PrivateDebugAPI) TraceTransaction(ctx context.Context, hash common.Hash, config *TraceConfig) (interface{}, error) {
|
func (api *PrivateDebugAPI) TraceTransaction(ctx context.Context, hash common.Hash, config *TraceConfig) (interface{}, error) {
|
||||||
// NOTE:SHYFT
|
// 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)
|
tx, blockHash, _, index := core.GetTransaction(api.eth.ChainDb(), hash)
|
||||||
if tx == nil {
|
if tx == nil {
|
||||||
return nil, fmt.Errorf("transaction %x not found", hash)
|
return nil, fmt.Errorf("transaction %x not found", hash)
|
||||||
}
|
}
|
||||||
|
|
||||||
reexec := defaultTraceReexec
|
reexec := defaultTraceReexec
|
||||||
if config != nil && config.Reexec != nil {
|
if config != nil && config.Reexec != nil {
|
||||||
reexec = *config.Reexec
|
reexec = *config.Reexec
|
||||||
|
|
@ -569,10 +560,11 @@ func (api *PrivateDebugAPI) traceTx(ctx context.Context, message core.Message, v
|
||||||
switch {
|
switch {
|
||||||
case config != nil && config.Tracer != nil:
|
case config != nil && config.Tracer != nil:
|
||||||
// Define a meaningful timeout of a single transaction trace
|
// Define a meaningful timeout of a single transaction trace
|
||||||
timeout := defaultTraceTimeout
|
|
||||||
fmt.Println(timeout)
|
_ = defaultTraceTimeout
|
||||||
|
|
||||||
if config.Timeout != nil {
|
if config.Timeout != nil {
|
||||||
if timeout, err = time.ParseDuration(*config.Timeout); err != nil {
|
if _, err = time.ParseDuration(*config.Timeout); err != nil {
|
||||||
return nil, err
|
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 {
|
if tracer, err = tracers.New(*config.Tracer); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
// NOTE:SHYFT REMOVED CTX DEADLINE
|
||||||
// Handle timeouts and RPC cancellations
|
// Handle timeouts and RPC cancellations
|
||||||
//deadlineCtx, cancel := context.WithTimeout(ctx, timeout)
|
//deadlineCtx, cancel := context.WithTimeout(ctx, timeout)
|
||||||
//go func() {
|
//go func() {
|
||||||
|
|
|
||||||
|
|
@ -579,9 +579,29 @@ type Internals struct {
|
||||||
From string
|
From string
|
||||||
To string
|
To string
|
||||||
Value string
|
Value string
|
||||||
|
Gas string
|
||||||
|
GasUsed string
|
||||||
Calls []*Internals
|
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
|
// GetResult calls the Javascript 'result' function and returns its value, or any accumulated error
|
||||||
func (jst *Tracer) GetResult() (json.RawMessage, error) {
|
func (jst *Tracer) GetResult() (json.RawMessage, error) {
|
||||||
// Transform the context into a JavaScript object and inject into the state
|
// 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.DestroyHeap()
|
||||||
jst.vm.Destroy()
|
jst.vm.Destroy()
|
||||||
|
|
||||||
//var dat map[string]interface{}
|
|
||||||
var dat Internals
|
var dat Internals
|
||||||
|
|
||||||
if err := json.Unmarshal(result, &dat); err != nil {
|
if err := json.Unmarshal(result, &dat); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
//fmt.Println("[FULL DATA]", string(result))
|
dat.InternalRecursive()
|
||||||
//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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return result, jst.err
|
return result, jst.err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue