forked from cerc-io/plugeth
Fix tracer loading
This commit is contained in:
+2
-1
@@ -40,6 +40,7 @@ import (
|
||||
"github.com/ethereum/go-ethereum/internal/ethapi"
|
||||
"github.com/ethereum/go-ethereum/log"
|
||||
"github.com/ethereum/go-ethereum/params"
|
||||
"github.com/ethereum/go-ethereum/plugins/interfaces"
|
||||
"github.com/ethereum/go-ethereum/rlp"
|
||||
"github.com/ethereum/go-ethereum/rpc"
|
||||
)
|
||||
@@ -850,7 +851,7 @@ func (api *API) traceTx(ctx context.Context, message core.Message, txctx *txTrac
|
||||
StructLogs: ethapi.FormatLogs(tracer.StructLogs()),
|
||||
}, nil
|
||||
|
||||
case TracerResult:
|
||||
case interfaces.TracerResult:
|
||||
return tracer.GetResult()
|
||||
|
||||
case *Tracer:
|
||||
|
||||
@@ -2,33 +2,30 @@ package tracers
|
||||
|
||||
import (
|
||||
"github.com/ethereum/go-ethereum/plugins"
|
||||
"github.com/ethereum/go-ethereum/core/vm"
|
||||
"github.com/ethereum/go-ethereum/plugins/interfaces"
|
||||
"github.com/ethereum/go-ethereum/core/state"
|
||||
"github.com/ethereum/go-ethereum/log"
|
||||
"reflect"
|
||||
)
|
||||
|
||||
|
||||
type TracerResult interface {
|
||||
vm.Tracer
|
||||
GetResult() (interface{}, error)
|
||||
}
|
||||
|
||||
func GetPluginTracer(pl *plugins.PluginLoader, name string) (func(*state.StateDB)TracerResult, bool) {
|
||||
func GetPluginTracer(pl *plugins.PluginLoader, name string) (func(*state.StateDB)interfaces.TracerResult, bool) {
|
||||
tracers := pl.Lookup("Tracers", func(item interface{}) bool {
|
||||
_, ok := item.(map[string]func(*state.StateDB)TracerResult)
|
||||
_, ok := item.(*map[string]func(*state.StateDB)interfaces.TracerResult)
|
||||
if !ok { log.Warn("Found tracer that did not match type", "tracer", reflect.TypeOf(item) ) }
|
||||
return ok
|
||||
})
|
||||
for _, tmap := range tracers {
|
||||
if tracerMap, ok := tmap.(map[string]func(*state.StateDB)TracerResult); ok {
|
||||
if tracer, ok := tracerMap[name]; ok {
|
||||
if tracerMap, ok := tmap.(*map[string]func(*state.StateDB)interfaces.TracerResult); ok {
|
||||
if tracer, ok := (*tracerMap)[name]; ok {
|
||||
return tracer, true
|
||||
}
|
||||
}
|
||||
}
|
||||
log.Info("Tracer not found", "name", name, "tracers", len(tracers))
|
||||
return nil, false
|
||||
}
|
||||
|
||||
func getPluginTracer(name string) (func(*state.StateDB)TracerResult, bool) {
|
||||
func getPluginTracer(name string) (func(*state.StateDB)interfaces.TracerResult, bool) {
|
||||
if plugins.DefaultPluginLoader == nil {
|
||||
log.Warn("Attempting GetPluginTracer, but default PluginLoader has not been initialized")
|
||||
return nil, false
|
||||
|
||||
Reference in New Issue
Block a user