From 3c62ba57d3d2f40b05a3b4de7575863e7e2886fa Mon Sep 17 00:00:00 2001 From: yyforyongyu Date: Thu, 19 Oct 2023 23:09:57 +0800 Subject: [PATCH] chainfee: make timeout values constant --- lnwallet/chainfee/estimator.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lnwallet/chainfee/estimator.go b/lnwallet/chainfee/estimator.go index dbeb87ee5..824af3f11 100644 --- a/lnwallet/chainfee/estimator.go +++ b/lnwallet/chainfee/estimator.go @@ -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, }