Commit b15eb665 authored by Lorenzo Manacorda's avatar Lorenzo Manacorda Committed by Felix Lange

ethclient: add DialContext and Close (#16318)

DialContext allows users to pass a Context object for cancellation.
Close closes the underlying RPC connection.
parent a16f12ba
...@@ -39,7 +39,11 @@ type Client struct { ...@@ -39,7 +39,11 @@ type Client struct {
// Dial connects a client to the given URL. // Dial connects a client to the given URL.
func Dial(rawurl string) (*Client, error) { func Dial(rawurl string) (*Client, error) {
c, err := rpc.Dial(rawurl) return DialContext(context.Background(), rawurl)
}
func DialContext(ctx context.Context, rawurl string) (*Client, error) {
c, err := rpc.DialContext(ctx, rawurl)
if err != nil { if err != nil {
return nil, err return nil, err
} }
...@@ -51,6 +55,10 @@ func NewClient(c *rpc.Client) *Client { ...@@ -51,6 +55,10 @@ func NewClient(c *rpc.Client) *Client {
return &Client{c} return &Client{c}
} }
func (ec *Client) Close() {
ec.c.Close()
}
// Blockchain Access // Blockchain Access
// BlockByHash returns the given full block. // BlockByHash returns the given full block.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment