Permalink
Browse files

ethclient: add DialContext and Close (#16318)

DialContext allows users to pass a Context object for cancellation.
Close closes the underlying RPC connection.
  • Loading branch information...
Lorenzo Manacorda authored and fjl committed Apr 19, 2018
1 parent a16f12b commit b15eb665ee3c373a361b050cd8fc726e31c4a750
Showing with 9 additions and 1 deletion.
  1. +9 −1 ethclient/ethclient.go
View
@@ -39,7 +39,11 @@ type Client struct {
// Dial connects a client to the given URL.
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 {
return nil, err
}
@@ -51,6 +55,10 @@ func NewClient(c *rpc.Client) *Client {
return &Client{c}
}
func (ec *Client) Close() {
ec.c.Close()
}
// Blockchain Access
// BlockByHash returns the given full block.

0 comments on commit b15eb66

Please sign in to comment.