Skip to content

Commit

Permalink
htlcswitch+peer: allow the disabling of quiescence
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ProofOfKeags committed Oct 2, 2024
1 parent 46130d6 commit 6a26e41
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 10 deletions.
29 changes: 19 additions & 10 deletions htlcswitch/link.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,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
Expand Down Expand Up @@ -482,16 +486,21 @@ func NewChannelLink(cfg ChannelLinkConfig,
cfg.MaxFeeExposure = DefaultMaxFeeExposure
}

qsm := newQuiescer(quiescerCfg{
chanID: lnwire.NewChanIDFromOutPoint(
channel.ChannelPoint(),
),
channelInitiator: channel.Initiator(),
numPendingUpdates: channel.NumPendingUpdates,
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(),
numPendingUpdates: channel.NumPendingUpdates,
sendMsg: func(s lnwire.Stfu) error {
return cfg.Peer.SendMessage(false, &s)
},
})
} else {
qsm = &quiescerNoop{}
}

quiescenceReqs := make(
chan fn.Req[fn.Unit, fn.Result[lntypes.ChannelParty]], 1,
Expand Down
6 changes: 6 additions & 0 deletions peer/brontide.go
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,10 @@ type Config struct {
// invalid.
DisallowRouteBlinding bool

// DisallowQuiescence is a flag that indicates whether the Brontide
// should have the quiescence feature disabled.
DisallowQuiescence bool

// MaxFeeExposure limits the number of outstanding fees in a channel.
// This value will be passed to created links.
MaxFeeExposure lnwire.MilliSatoshi
Expand Down Expand Up @@ -1347,6 +1351,8 @@ func (p *Brontide) addLink(chanPoint *wire.OutPoint,
GetAliases: p.cfg.GetAliases,
PreviouslySentShutdown: shutdownMsg,
DisallowRouteBlinding: p.cfg.DisallowRouteBlinding,
DisallowQuiescence: p.cfg.DisallowQuiescence ||
!p.remoteFeatures.HasFeature(lnwire.QuiescenceOptional),
MaxFeeExposure: p.cfg.MaxFeeExposure,
}

Expand Down

0 comments on commit 6a26e41

Please sign in to comment.