mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 15:16:43 +00:00
# Conflicts # core/vm/interpreter.go # eth/tracers/directory/noop.go # eth/tracers/js/goja.go # eth/tracers/live/noop.go # eth/tracers/logger/logger.go # eth/tracers/logger/logger_json.go # eth/tracers/native/4byte.go # eth/tracers/native/call.go # eth/tracers/native/call_flat.go # eth/tracers/native/mux.go
31 lines
736 B
Go
31 lines
736 B
Go
package live
|
|
|
|
import (
|
|
"encoding/json"
|
|
"errors"
|
|
|
|
"github.com/ethereum/go-ethereum/core/tracing"
|
|
)
|
|
|
|
type ctorFunc func(config json.RawMessage) (*tracing.Hooks, error)
|
|
|
|
// Directory is the collection of tracers which can be used
|
|
// during normal block import operations.
|
|
var Directory = directory{elems: make(map[string]ctorFunc)}
|
|
|
|
type directory struct {
|
|
elems map[string]ctorFunc
|
|
}
|
|
|
|
// Register registers a tracer constructor by name.
|
|
func (d *directory) Register(name string, f ctorFunc) {
|
|
d.elems[name] = f
|
|
}
|
|
|
|
// New instantiates a tracer by name.
|
|
func (d *directory) New(name string, config json.RawMessage) (*tracing.Hooks, error) {
|
|
if f, ok := d.elems[name]; ok {
|
|
return f(config)
|
|
}
|
|
return nil, errors.New("not found")
|
|
}
|