htlcswitch+peer: allow the disabling of quiescence

Here we add a flag where we can disable quiescence. This will be used
in the case where the feature is not negotiated with our peer.
This commit is contained in:
Keagan McClelland
2024-08-09 20:33:34 -07:00
parent 48ee643c0d
commit 111c9b05f3
7 changed files with 49 additions and 9 deletions

View File

@@ -283,6 +283,10 @@ type ChannelLinkConfig struct {
// invalid.
DisallowRouteBlinding bool
// DisallowQuiescence is a flag that can be used to disable the
// quiescence protocol.
DisallowQuiescence bool
// MaxFeeExposure is the threshold in milli-satoshis after which we'll
// restrict the flow of HTLCs and fee updates.
MaxFeeExposure lnwire.MilliSatoshi
@@ -476,14 +480,19 @@ func NewChannelLink(cfg ChannelLinkConfig,
cfg.MaxFeeExposure = DefaultMaxFeeExposure
}
quiescerCfg := QuiescerCfg{
chanID: lnwire.NewChanIDFromOutPoint(
channel.ChannelPoint(),
),
channelInitiator: channel.Initiator(),
sendMsg: func(s lnwire.Stfu) error {
return cfg.Peer.SendMessage(false, &s)
},
var qsm Quiescer
if !cfg.DisallowQuiescence {
qsm = NewQuiescer(QuiescerCfg{
chanID: lnwire.NewChanIDFromOutPoint(
channel.ChannelPoint(),
),
channelInitiator: channel.Initiator(),
sendMsg: func(s lnwire.Stfu) error {
return cfg.Peer.SendMessage(false, &s)
},
})
} else {
qsm = &quiescerNoop{}
}
quiescenceReqs := make(
@@ -499,7 +508,7 @@ func NewChannelLink(cfg ChannelLinkConfig,
flushHooks: newHookMap(),
outgoingCommitHooks: newHookMap(),
incomingCommitHooks: newHookMap(),
quiescer: NewQuiescer(quiescerCfg),
quiescer: qsm,
quiescenceReqs: quiescenceReqs,
ContextGuard: fn.NewContextGuard(),
}