mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-17 17:33:47 +00:00
ethclient: add DialContext function
Allows users to pass a Context object for cancellation.
This commit is contained in:
parent
a063876749
commit
cbabb84560
1 changed files with 8 additions and 0 deletions
|
|
@ -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}
|
||||
|
|
|
|||
Loading…
Reference in a new issue