From e8b20354845604f48acf864f4940bd57c59eb9e2 Mon Sep 17 00:00:00 2001 From: yyforyongyu Date: Mon, 30 Jun 2025 20:45:28 +0800 Subject: [PATCH] htlcswitch: add handler `handleQuiescenceReq` --- htlcswitch/link.go | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/htlcswitch/link.go b/htlcswitch/link.go index 0842a8c3c..441ea5fcc 100644 --- a/htlcswitch/link.go +++ b/htlcswitch/link.go @@ -1517,18 +1517,13 @@ func (l *channelLink) htlcManager(ctx context.Context) { "resolution: %v", err) } + // A user-initiated quiescence request is received. We now + // forward it to the quiescer. case qReq := <-l.quiescenceReqs: - l.quiescer.InitStfu(qReq) - - if l.noDanglingUpdates(lntypes.Local) { - err := l.quiescer.SendOwedStfu() - if err != nil { - l.stfuFailf( - "SendOwedStfu: %s", err.Error(), - ) - res := fn.Err[lntypes.ChannelParty](err) - qReq.Resolve(res) - } + err := l.handleQuiescenceReq(qReq) + if err != nil { + l.log.Errorf("failed handle quiescence "+ + "req: %v", err) } case <-l.cg.Done(): @@ -4605,3 +4600,22 @@ func (l *channelLink) handleHtlcResolution(ctx context.Context, return err } + +// handleQuiescenceReq takes a locally initialized (RPC) quiescence request and +// forwards it to the quiescer for further processing. +func (l *channelLink) handleQuiescenceReq(req StfuReq) error { + l.quiescer.InitStfu(req) + + if !l.noDanglingUpdates(lntypes.Local) { + return nil + } + + err := l.quiescer.SendOwedStfu() + if err != nil { + l.stfuFailf("SendOwedStfu: %s", err.Error()) + res := fn.Err[lntypes.ChannelParty](err) + req.Resolve(res) + } + + return err +}