ethclient: add DialContext function

Allows users to pass a Context object for cancellation.
This commit is contained in:
Lorenzo Manacorda 2018-03-14 21:40:26 +01:00
parent a063876749
commit cbabb84560

View file

@ -46,6 +46,14 @@ func Dial(rawurl string) (*Client, error) {
return NewClient(c), nil
}
func DialContext(ctx context.Context, rawurl string) (*Client, error) {
c, err := rpc.DialContext(ctx, rawurl)
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}