diff --git a/cmd/faucet/faucet.go b/cmd/faucet/faucet.go index 581629da5e1cb..e4d6ad6977508 100644 --- a/cmd/faucet/faucet.go +++ b/cmd/faucet/faucet.go @@ -268,11 +268,7 @@ func newFaucet(genesis *core.Genesis, port int, enodes []*enode.Node, network ui } } // Attach to the client and retrieve and interesting metadatas - api, err := stack.Attach() - if err != nil { - stack.Close() - return nil, err - } + api := stack.Attach() client := ethclient.NewClient(api) return &faucet{ diff --git a/cmd/geth/consolecmd.go b/cmd/geth/consolecmd.go index aeee6f9c9e404..526ede96192fa 100644 --- a/cmd/geth/consolecmd.go +++ b/cmd/geth/consolecmd.go @@ -75,10 +75,7 @@ func localConsole(ctx *cli.Context) error { defer stack.Close() // Attach to the newly started node and create the JavaScript console. - client, err := stack.Attach() - if err != nil { - return fmt.Errorf("failed to attach to the inproc geth: %v", err) - } + client := stack.Attach() config := console.Config{ DataDir: utils.MakeDataDir(ctx), DocRoot: ctx.String(utils.JSpathFlag.Name), diff --git a/cmd/geth/main.go b/cmd/geth/main.go index 2289a72a197b9..152ac88d7b5c1 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -344,10 +344,7 @@ func startNode(ctx *cli.Context, stack *node.Node, backend ethapi.Backend, isCon stack.AccountManager().Subscribe(events) // Create a client to interact with local geth node. - rpcClient, err := stack.Attach() - if err != nil { - utils.Fatalf("Failed to attach to self: %v", err) - } + rpcClient := stack.Attach() ethClient := ethclient.NewClient(rpcClient) go func() { diff --git a/console/console_test.go b/console/console_test.go index cc61f021ce1d4..a2550d8ca8ae6 100644 --- a/console/console_test.go +++ b/console/console_test.go @@ -110,10 +110,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/ethclient/ethclient_test.go b/ethclient/ethclient_test.go index 3856760756553..d2f3710936611 100644 --- a/ethclient/ethclient_test.go +++ b/ethclient/ethclient_test.go @@ -250,7 +250,7 @@ func generateTestChain() []*types.Block { func TestEthClient(t *testing.T) { backend, chain := newTestBackend(t) - client, _ := backend.Attach() + client := backend.Attach() defer backend.Close() defer client.Close() diff --git a/ethclient/gethclient/gethclient_test.go b/ethclient/gethclient/gethclient_test.go index 296d328484513..7ff5836f81df7 100644 --- a/ethclient/gethclient/gethclient_test.go +++ b/ethclient/gethclient/gethclient_test.go @@ -94,10 +94,7 @@ func generateTestChain() (*core.Genesis, []*types.Block) { func TestGethClient(t *testing.T) { backend, _ := newTestBackend(t) - client, err := backend.Attach() - if err != nil { - t.Fatal(err) - } + client := backend.Attach() defer backend.Close() defer client.Close() diff --git a/node/node.go b/node/node.go index e8494ac3b29e1..92a35e261b5eb 100644 --- a/node/node.go +++ b/node/node.go @@ -605,8 +605,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 36b5286517ae7..c52917fd0ae59 100644 --- a/p2p/simulations/adapters/inproc.go +++ b/p2p/simulations/adapters/inproc.go @@ -147,7 +147,7 @@ func (s *SimAdapter) DialRPC(id enode.ID) (*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 @@ -274,10 +274,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 sn.lock.Unlock()