channelnotifier: add InactiveLinkEvent

This commit adds a new event `InactiveLinkEvent` to be used when a link
becomes inactive.
This commit is contained in:
yyforyongyu 2022-11-24 06:57:53 +08:00
parent ea0eb2ce72
commit ced8833895
No known key found for this signature in database
GPG Key ID: 9BCD95C4FF296868
2 changed files with 24 additions and 3 deletions

View File

@ -47,6 +47,13 @@ type ActiveLinkEvent struct {
ChannelPoint *wire.OutPoint ChannelPoint *wire.OutPoint
} }
// InactiveLinkEvent represents a new event where the link becomes inactive in
// the switch.
type InactiveLinkEvent struct {
// ChannelPoint is the channel point for the inactive channel.
ChannelPoint *wire.OutPoint
}
// ActiveChannelEvent represents a new event where a channel becomes active. // ActiveChannelEvent represents a new event where a channel becomes active.
type ActiveChannelEvent struct { type ActiveChannelEvent struct {
// ChannelPoint is the channelpoint for the newly active channel. // ChannelPoint is the channelpoint for the newly active channel.
@ -193,6 +200,15 @@ func (c *ChannelNotifier) NotifyActiveChannelEvent(chanPoint wire.OutPoint) {
} }
} }
// NotifyInactiveLinkEvent notifies the channelEventNotifier goroutine that a
// link has been removed from the switch.
func (c *ChannelNotifier) NotifyInactiveLinkEvent(chanPoint wire.OutPoint) {
event := InactiveLinkEvent{ChannelPoint: &chanPoint}
if err := c.ntfnServer.SendUpdate(event); err != nil {
log.Warnf("Unable to send inactive link update: %v", err)
}
}
// NotifyInactiveChannelEvent notifies the channelEventNotifier goroutine that a // NotifyInactiveChannelEvent notifies the channelEventNotifier goroutine that a
// channel is inactive. // channel is inactive.
func (c *ChannelNotifier) NotifyInactiveChannelEvent(chanPoint wire.OutPoint) { func (c *ChannelNotifier) NotifyInactiveChannelEvent(chanPoint wire.OutPoint) {

View File

@ -4624,9 +4624,12 @@ func (r *rpcServer) SubscribeChannelEvents(req *lnrpc.ChannelEventSubscription,
}, },
} }
// Completely ignore ActiveLinkEvent as this is explicitly not // Completely ignore ActiveLinkEvent and
// exposed to the RPC. // InactiveLinkEvent as this is explicitly not exposed
case channelnotifier.ActiveLinkEvent: // to the RPC.
case channelnotifier.ActiveLinkEvent,
channelnotifier.InactiveLinkEvent:
continue continue
case channelnotifier.FullyResolvedChannelEvent: case channelnotifier.FullyResolvedChannelEvent:
@ -7323,6 +7326,8 @@ func (r *rpcServer) SubscribeChannelBackups(req *lnrpc.ChannelBackupSubscription
continue continue
case channelnotifier.ActiveLinkEvent: case channelnotifier.ActiveLinkEvent:
continue continue
case channelnotifier.InactiveLinkEvent:
continue
} }
// Now that we know the channel state has changed, // Now that we know the channel state has changed,