mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-07-15 15:42:38 +02:00
lntest: do not do IO under mutex in fee_service
If HTTP response is consumed slowly, this might block other HTTP requests to the fee service, because the mutex is held.
This commit is contained in:
@ -115,14 +115,13 @@ func (f *FeeService) Start() error {
|
|||||||
// handleRequest handles a client request for fee estimates.
|
// handleRequest handles a client request for fee estimates.
|
||||||
func (f *FeeService) handleRequest(w http.ResponseWriter, _ *http.Request) {
|
func (f *FeeService) handleRequest(w http.ResponseWriter, _ *http.Request) {
|
||||||
f.lock.Lock()
|
f.lock.Lock()
|
||||||
defer f.lock.Unlock()
|
|
||||||
|
|
||||||
bytes, err := json.Marshal(
|
bytes, err := json.Marshal(
|
||||||
chainfee.WebAPIResponse{
|
chainfee.WebAPIResponse{
|
||||||
FeeByBlockTarget: f.feeRateMap,
|
FeeByBlockTarget: f.feeRateMap,
|
||||||
MinRelayFeerate: f.minRelayFeerate,
|
MinRelayFeerate: f.minRelayFeerate,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
f.lock.Unlock()
|
||||||
require.NoErrorf(f, err, "cannot serialize estimates")
|
require.NoErrorf(f, err, "cannot serialize estimates")
|
||||||
|
|
||||||
_, err = io.WriteString(w, string(bytes))
|
_, err = io.WriteString(w, string(bytes))
|
||||||
|
Reference in New Issue
Block a user