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:
Boris Nagaev
2025-06-24 00:44:45 -03:00
parent 45c15646c6
commit 61b3670113

View File

@ -115,14 +115,13 @@ func (f *FeeService) Start() error {
// handleRequest handles a client request for fee estimates.
func (f *FeeService) handleRequest(w http.ResponseWriter, _ *http.Request) {
f.lock.Lock()
defer f.lock.Unlock()
bytes, err := json.Marshal(
chainfee.WebAPIResponse{
FeeByBlockTarget: f.feeRateMap,
MinRelayFeerate: f.minRelayFeerate,
},
)
f.lock.Unlock()
require.NoErrorf(f, err, "cannot serialize estimates")
_, err = io.WriteString(w, string(bytes))