htlcswitch: add handler handleQuiescenceReq

This commit is contained in:
yyforyongyu
2025-06-30 20:45:28 +08:00
parent 30f9257a6b
commit e8b2035484

View File

@@ -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
}