Skip to content

Commit f9d7731

Browse files
committed
add NewWithTimeout ,default 30s for timeout is too long for some case
1 parent e42397d commit f9d7731

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

client.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,17 @@ type Client struct {
3838
AfterRequest func(module, action string, param map[string]interface{}, outcome interface{}, requestErr error)
3939
}
4040

41+
func NewWithTimeout(network Network, APIKey string, timeout int) *Client {
42+
return &Client{
43+
coon: &http.Client{
44+
Timeout: time.Duration(timeout) * time.Second,
45+
},
46+
network: network,
47+
key: APIKey,
48+
baseURL: fmt.Sprintf(`https://%s.etherscan.io/api?`, network.SubDomain()),
49+
}
50+
}
51+
4152
// New initialize a new etherscan API client
4253
// please use pre-defined network value
4354
func New(network Network, APIKey string) *Client {

0 commit comments

Comments
 (0)