From d267c7d976d9a3978a07c452df1ddebf21d09a66 Mon Sep 17 00:00:00 2001 From: Sina Mahmoodi Date: Wed, 20 Mar 2024 18:03:09 +0100 Subject: [PATCH] move live directory to main directory module --- cmd/utils/flags.go | 4 ++-- eth/backend.go | 4 ++-- eth/tracers/directory/{live/dir.go => live.go} | 12 ++++++------ eth/tracers/live/noop.go | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) rename eth/tracers/directory/{live/dir.go => live.go} (56%) diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 928dd2cb9d..31f7320b4b 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -52,7 +52,7 @@ import ( "github.com/ethereum/go-ethereum/eth/filters" "github.com/ethereum/go-ethereum/eth/gasprice" "github.com/ethereum/go-ethereum/eth/tracers" - "github.com/ethereum/go-ethereum/eth/tracers/directory/live" + "github.com/ethereum/go-ethereum/eth/tracers/directory" "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/ethdb/remotedb" "github.com/ethereum/go-ethereum/ethstats" @@ -2215,7 +2215,7 @@ func MakeChain(ctx *cli.Context, stack *node.Node, readonly bool) (*core.BlockCh if ctx.IsSet(VMTraceConfigFlag.Name) { config = json.RawMessage(ctx.String(VMTraceConfigFlag.Name)) } - t, err := live.Directory.New(name, config) + t, err := directory.LiveDirectory.New(name, config) if err != nil { Fatalf("Failed to create tracer %q: %v", name, err) } diff --git a/eth/backend.go b/eth/backend.go index 746266cd10..2d75866d90 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -45,7 +45,7 @@ import ( "github.com/ethereum/go-ethereum/eth/gasprice" "github.com/ethereum/go-ethereum/eth/protocols/eth" "github.com/ethereum/go-ethereum/eth/protocols/snap" - "github.com/ethereum/go-ethereum/eth/tracers/directory/live" + "github.com/ethereum/go-ethereum/eth/tracers/directory" "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/internal/ethapi" @@ -212,7 +212,7 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) { if config.VMTraceConfig != "" { traceConfig = json.RawMessage(config.VMTraceConfig) } - t, err := live.Directory.New(config.VMTrace, traceConfig) + t, err := directory.LiveDirectory.New(config.VMTrace, traceConfig) if err != nil { return nil, fmt.Errorf("Failed to create tracer %s: %v", config.VMTrace, err) } diff --git a/eth/tracers/directory/live/dir.go b/eth/tracers/directory/live.go similarity index 56% rename from eth/tracers/directory/live/dir.go rename to eth/tracers/directory/live.go index cedf81c35e..6f9b0fd72b 100644 --- a/eth/tracers/directory/live/dir.go +++ b/eth/tracers/directory/live.go @@ -1,4 +1,4 @@ -package live +package directory import ( "encoding/json" @@ -9,21 +9,21 @@ import ( type ctorFunc func(config json.RawMessage) (*tracing.Hooks, error) -// Directory is the collection of tracers which can be used +// LiveDirectory is the collection of tracers which can be used // during normal block import operations. -var Directory = directory{elems: make(map[string]ctorFunc)} +var LiveDirectory = liveDirectory{elems: make(map[string]ctorFunc)} -type directory struct { +type liveDirectory struct { elems map[string]ctorFunc } // Register registers a tracer constructor by name. -func (d *directory) Register(name string, f ctorFunc) { +func (d *liveDirectory) 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) { +func (d *liveDirectory) New(name string, config json.RawMessage) (*tracing.Hooks, error) { if f, ok := d.elems[name]; ok { return f(config) } diff --git a/eth/tracers/live/noop.go b/eth/tracers/live/noop.go index 2236674201..596661d7cc 100644 --- a/eth/tracers/live/noop.go +++ b/eth/tracers/live/noop.go @@ -7,12 +7,12 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/tracing" "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/eth/tracers/directory/live" + "github.com/ethereum/go-ethereum/eth/tracers/directory" "github.com/ethereum/go-ethereum/params" ) func init() { - live.Directory.Register("noop", newNoopTracer) + directory.LiveDirectory.Register("noop", newNoopTracer) } // noop is a no-op live tracer. It's there to