mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-01-18 05:13:36 +01:00
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:
parent
48ee643c0d
commit
111c9b05f3
@ -84,6 +84,10 @@ var defaultSetDesc = setDesc{
|
||||
SetNodeAnn: {}, // N
|
||||
SetInvoice: {}, // 9
|
||||
},
|
||||
lnwire.QuiescenceOptional: {
|
||||
SetInit: {}, // I
|
||||
SetNodeAnn: {}, // N
|
||||
},
|
||||
lnwire.ShutdownAnySegwitOptional: {
|
||||
SetInit: {}, // I
|
||||
SetNodeAnn: {}, // N
|
||||
|
@ -63,6 +63,9 @@ type Config struct {
|
||||
// NoRouteBlinding unsets route blinding feature bits.
|
||||
NoRouteBlinding bool
|
||||
|
||||
// NoQuiescence unsets quiescence feature bits.
|
||||
NoQuiescence bool
|
||||
|
||||
// NoTaprootOverlay unsets the taproot overlay channel feature bits.
|
||||
NoTaprootOverlay bool
|
||||
|
||||
@ -199,6 +202,9 @@ func newManager(cfg Config, desc setDesc) (*Manager, error) {
|
||||
raw.Unset(lnwire.Bolt11BlindedPathsOptional)
|
||||
raw.Unset(lnwire.Bolt11BlindedPathsRequired)
|
||||
}
|
||||
if cfg.NoQuiescence {
|
||||
raw.Unset(lnwire.QuiescenceOptional)
|
||||
}
|
||||
if cfg.NoTaprootOverlay {
|
||||
raw.Unset(lnwire.SimpleTaprootOverlayChansOptional)
|
||||
raw.Unset(lnwire.SimpleTaprootOverlayChansRequired)
|
||||
|
@ -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(),
|
||||
}
|
||||
|
@ -141,6 +141,11 @@ func (l *ProtocolOptions) NoExperimentalEndorsement() bool {
|
||||
return l.NoExperimentalEndorsementOption
|
||||
}
|
||||
|
||||
// NoQuiescence returns true if quiescence is disabled.
|
||||
func (l *ProtocolOptions) NoQuiescence() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// CustomMessageOverrides returns the set of protocol messages that we override
|
||||
// to allow custom handling.
|
||||
func (p ProtocolOptions) CustomMessageOverrides() []uint16 {
|
||||
|
@ -73,6 +73,9 @@ type ProtocolOptions struct {
|
||||
// NoExperimentalEndorsementOption disables experimental endorsement.
|
||||
NoExperimentalEndorsementOption bool `long:"no-experimental-endorsement" description:"do not forward experimental endorsement signals"`
|
||||
|
||||
// NoQuiescenceOption disables quiescence for all channels.
|
||||
NoQuiescenceOption bool `long:"no-quiescence" description:"do not allow or advertise quiescence for any channel"`
|
||||
|
||||
// CustomMessage allows the custom message APIs to handle messages with
|
||||
// the provided protocol numbers, which fall outside the custom message
|
||||
// number range.
|
||||
@ -136,6 +139,11 @@ func (l *ProtocolOptions) NoExperimentalEndorsement() bool {
|
||||
return l.NoExperimentalEndorsementOption
|
||||
}
|
||||
|
||||
// NoQuiescence returns true if quiescence is disabled.
|
||||
func (l *ProtocolOptions) NoQuiescence() bool {
|
||||
return l.NoQuiescenceOption
|
||||
}
|
||||
|
||||
// CustomMessageOverrides returns the set of protocol messages that we override
|
||||
// to allow custom handling.
|
||||
func (l ProtocolOptions) CustomMessageOverrides() []uint16 {
|
||||
|
@ -411,6 +411,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
|
||||
@ -1324,6 +1328,8 @@ func (p *Brontide) addLink(chanPoint *wire.OutPoint,
|
||||
DisallowRouteBlinding: p.cfg.DisallowRouteBlinding,
|
||||
MaxFeeExposure: p.cfg.MaxFeeExposure,
|
||||
ShouldFwdExpEndorsement: p.cfg.ShouldFwdExpEndorsement,
|
||||
DisallowQuiescence: p.cfg.DisallowQuiescence ||
|
||||
!p.remoteFeatures.HasFeature(lnwire.QuiescenceOptional),
|
||||
}
|
||||
|
||||
// Before adding our new link, purge the switch of any pending or live
|
||||
|
@ -587,6 +587,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
|
||||
NoTaprootOverlay: !cfg.ProtocolOptions.TaprootOverlayChans,
|
||||
NoRouteBlinding: cfg.ProtocolOptions.NoRouteBlinding(),
|
||||
NoExperimentalEndorsement: cfg.ProtocolOptions.NoExperimentalEndorsement(),
|
||||
NoQuiescence: cfg.ProtocolOptions.NoQuiescence(),
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -4214,6 +4215,7 @@ func (s *server) peerConnected(conn net.Conn, connReq *connmgr.ConnReq,
|
||||
RequestAlias: s.aliasMgr.RequestAlias,
|
||||
AddLocalAlias: s.aliasMgr.AddLocalAlias,
|
||||
DisallowRouteBlinding: s.cfg.ProtocolOptions.NoRouteBlinding(),
|
||||
DisallowQuiescence: s.cfg.ProtocolOptions.NoQuiescence(),
|
||||
MaxFeeExposure: thresholdMSats,
|
||||
Quit: s.quit,
|
||||
AuxLeafStore: s.implCfg.AuxLeafStore,
|
||||
|
Loading…
Reference in New Issue
Block a user