diff options
author | Lorenzo Manacorda <lorenzo@kinvolk.io> | 2018-04-19 21:36:33 +0800 |
---|---|---|
committer | Felix Lange <fjl@users.noreply.github.com> | 2018-04-19 21:36:33 +0800 |
commit | b15eb665ee3c373a361b050cd8fc726e31c4a750 (patch) | |
tree | 4b1d926efce2b7858f9397d034f9b84323c7eb14 /ethclient | |
parent | a16f12ba8695c15b5dac7a7fbb30c9177672bf8f (diff) | |
download | go-tangerine-b15eb665ee3c373a361b050cd8fc726e31c4a750.tar go-tangerine-b15eb665ee3c373a361b050cd8fc726e31c4a750.tar.gz go-tangerine-b15eb665ee3c373a361b050cd8fc726e31c4a750.tar.bz2 go-tangerine-b15eb665ee3c373a361b050cd8fc726e31c4a750.tar.lz go-tangerine-b15eb665ee3c373a361b050cd8fc726e31c4a750.tar.xz go-tangerine-b15eb665ee3c373a361b050cd8fc726e31c4a750.tar.zst go-tangerine-b15eb665ee3c373a361b050cd8fc726e31c4a750.zip |
ethclient: add DialContext and Close (#16318)
DialContext allows users to pass a Context object for cancellation.
Close closes the underlying RPC connection.
Diffstat (limited to 'ethclient')
-rw-r--r-- | ethclient/ethclient.go | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/ethclient/ethclient.go b/ethclient/ethclient.go index 7349d6fba..b48224587 100644 --- a/ethclient/ethclient.go +++ b/ethclient/ethclient.go @@ -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. |