From 1c5b5ea8837eecc241999f363fa3963f413a9e21 Mon Sep 17 00:00:00 2001 From: JukLee0ira Date: Thu, 26 Jun 2025 10:51:24 +0800 Subject: [PATCH] node: remove unused error return from Attach #27450 (#1155) --- cmd/XDC/consolecmd.go | 10 ++-------- cmd/XDC/main.go | 5 +---- console/console_test.go | 5 +---- node/node.go | 4 ++-- p2p/simulations/adapters/inproc.go | 7 ++----- 5 files changed, 8 insertions(+), 23 deletions(-) diff --git a/cmd/XDC/consolecmd.go b/cmd/XDC/consolecmd.go index 190e5e212b..759c26f149 100644 --- a/cmd/XDC/consolecmd.go +++ b/cmd/XDC/consolecmd.go @@ -80,10 +80,7 @@ func localConsole(ctx *cli.Context) error { defer stack.Close() // Attach to the newly started node and start the JavaScript console - client, err := stack.Attach() - if err != nil { - utils.Fatalf("failed to attach to the inproc XDC: %v", err) - } + client := stack.Attach() config := console.Config{ DataDir: utils.MakeDataDir(ctx), DocRoot: ctx.String(utils.JSpathFlag.Name), @@ -185,10 +182,7 @@ func ephemeralConsole(ctx *cli.Context) error { defer stack.Close() // Attach to the newly started node and start the JavaScript console - client, err := stack.Attach() - if err != nil { - utils.Fatalf("Failed to attach to the inproc XDC: %v", err) - } + client := stack.Attach() config := console.Config{ DataDir: utils.MakeDataDir(ctx), DocRoot: ctx.String(utils.JSpathFlag.Name), diff --git a/cmd/XDC/main.go b/cmd/XDC/main.go index 0fa41c9113..07446a82e3 100644 --- a/cmd/XDC/main.go +++ b/cmd/XDC/main.go @@ -306,10 +306,7 @@ func startNode(ctx *cli.Context, stack *node.Node, backend ethapi.Backend, cfg X go func() { // Create an chain state reader for self-derivation - rpcClient, err := stack.Attach() - if err != nil { - utils.Fatalf("Failed to attach to self: %v", err) - } + rpcClient := stack.Attach() stateReader := ethclient.NewClient(rpcClient) // Open any wallets already attached diff --git a/console/console_test.go b/console/console_test.go index acc710d222..30136353a7 100644 --- a/console/console_test.go +++ b/console/console_test.go @@ -112,10 +112,7 @@ func newTester(t *testing.T, confOverride func(*ethconfig.Config)) *tester { if err = stack.Start(); err != nil { t.Fatalf("failed to start test stack: %v", err) } - client, err := stack.Attach() - if err != nil { - t.Fatalf("failed to attach to node: %v", err) - } + client := stack.Attach() prompter := &hookedPrompter{scheduler: make(chan string)} printer := new(bytes.Buffer) diff --git a/node/node.go b/node/node.go index ea9847db47..6c7984f0d7 100644 --- a/node/node.go +++ b/node/node.go @@ -630,8 +630,8 @@ func (n *Node) RegisterHandler(name, path string, handler http.Handler) { } // Attach creates an RPC client attached to an in-process API handler. -func (n *Node) Attach() (*rpc.Client, error) { - return rpc.DialInProc(n.inprocHandler), nil +func (n *Node) Attach() *rpc.Client { + return rpc.DialInProc(n.inprocHandler) } // RPCHandler returns the in-process RPC request handler. diff --git a/p2p/simulations/adapters/inproc.go b/p2p/simulations/adapters/inproc.go index 908ee4ea3c..cf9c67d683 100644 --- a/p2p/simulations/adapters/inproc.go +++ b/p2p/simulations/adapters/inproc.go @@ -131,7 +131,7 @@ func (sa *SimAdapter) DialRPC(id discover.NodeID) (*rpc.Client, error) { if !ok { return nil, fmt.Errorf("unknown node: %s", id) } - return node.node.Attach() + return node.node.Attach(), nil } // GetNode returns the node with the given ID if it exists @@ -261,10 +261,7 @@ func (sn *SimNode) Start(snapshots map[string][]byte) error { } // create an in-process RPC client - client, err := sn.node.Attach() - if err != nil { - return err - } + client := sn.node.Attach() sn.lock.Lock() sn.client = client