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
2 changed files with 24 additions and 3 deletions

View File

@@ -47,6 +47,13 @@ type ActiveLinkEvent struct {
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.
type ActiveChannelEvent struct {
// 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
// channel is inactive.
func (c *ChannelNotifier) NotifyInactiveChannelEvent(chanPoint wire.OutPoint) {