From c8b0afb2c449580b45171a6343ce8cc4226587e2 Mon Sep 17 00:00:00 2001 From: Delweng Date: Thu, 11 May 2023 15:09:16 +0800 Subject: [PATCH] ethclient: acquire the rpc.Client (#27246) Signed-off-by: jsvisa --- ethclient/ethclient.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ethclient/ethclient.go b/ethclient/ethclient.go index 47beaf63c..09d3f37d1 100644 --- a/ethclient/ethclient.go +++ b/ethclient/ethclient.go @@ -41,6 +41,7 @@ func Dial(rawurl string) (*Client, error) { return DialContext(context.Background(), rawurl) } +// DialContext connects a client to the given URL with context. func DialContext(ctx context.Context, rawurl string) (*Client, error) { c, err := rpc.DialContext(ctx, rawurl) if err != nil { @@ -54,10 +55,16 @@ func NewClient(c *rpc.Client) *Client { return &Client{c} } +// Close closes the underlying RPC connection. func (ec *Client) Close() { ec.c.Close() } +// Client gets the underlying RPC client. +func (ec *Client) Client() *rpc.Client { + return ec.c +} + // Blockchain Access // ChainID retrieves the current chain ID for transaction replay protection.