From 7f99420eea5c4876bd70c24ca4b527c1f7afb493 Mon Sep 17 00:00:00 2001 From: constwz Date: Thu, 15 Aug 2024 14:09:24 +0800 Subject: [PATCH] perf: add DialOptions function for Dial --- ethclient/ethclient.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ethclient/ethclient.go b/ethclient/ethclient.go index d01aab51f1..87892b6450 100644 --- a/ethclient/ethclient.go +++ b/ethclient/ethclient.go @@ -50,6 +50,16 @@ func DialContext(ctx context.Context, rawurl string) (*Client, error) { return NewClient(c), nil } +// DialOptions creates a new RPC client for the given URL. You can supply any of the +// pre-defined client options to configure the underlying transport. +func DialOptions(ctx context.Context, rawurl string, opts ...rpc.ClientOption) (*Client, error) { + c, err := rpc.DialOptions(ctx, rawurl, opts...) + if err != nil { + return nil, err + } + return NewClient(c), nil +} + // NewClient creates a client that uses the given RPC client. func NewClient(c *rpc.Client) *Client { return &Client{c}