chainfee: make timeout values constant

This commit is contained in:
yyforyongyu 2023-10-19 23:09:57 +08:00
parent 090892c613
commit 3c62ba57d3
No known key found for this signature in database
GPG Key ID: 9BCD95C4FF296868

View File

@ -35,6 +35,14 @@ const (
// maxFeeUpdateTimeout represents the maximum interval in which a
// WebAPIEstimator will request fresh fees from its API.
maxFeeUpdateTimeout = 20 * time.Minute
// WebAPIConnectionTimeout specifies the timeout value for connecting
// to the api source.
WebAPIConnectionTimeout = 5 * time.Second
// WebAPIResponseTimeout specifies the timeout value for receiving a
// fee response from the api source.
WebAPIResponseTimeout = 10 * time.Second
)
var (
@ -537,12 +545,12 @@ func (s SparseConfFeeSource) GetFeeMap() (map[uint32]uint32, error) {
// overloaded, we can exit early and use our default fee.
netTransport := &http.Transport{
Dial: (&net.Dialer{
Timeout: 5 * time.Second,
Timeout: WebAPIConnectionTimeout,
}).Dial,
TLSHandshakeTimeout: 5 * time.Second,
TLSHandshakeTimeout: WebAPIConnectionTimeout,
}
netClient := &http.Client{
Timeout: time.Second * 10,
Timeout: WebAPIResponseTimeout,
Transport: netTransport,
}