From f5237589ea6c214c81b30d0846b47a6b7c7caeed Mon Sep 17 00:00:00 2001 From: nsa Date: Fri, 6 Mar 2020 22:38:39 -0500 Subject: [PATCH] channelnotifier: new ActiveLinkEvent for link startup notification --- channelnotifier/channelnotifier.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/channelnotifier/channelnotifier.go b/channelnotifier/channelnotifier.go index e6a1fada..5d67fd51 100644 --- a/channelnotifier/channelnotifier.go +++ b/channelnotifier/channelnotifier.go @@ -40,6 +40,13 @@ type OpenChannelEvent struct { Channel *channeldb.OpenChannel } +// ActiveLinkEvent represents a new event where the link becomes active in the +// switch. This happens before the ActiveChannelEvent. +type ActiveLinkEvent struct { + // ChannelPoint is the channel point for the newly active 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. @@ -146,6 +153,15 @@ func (c *ChannelNotifier) NotifyClosedChannelEvent(chanPoint wire.OutPoint) { } } +// NotifyActiveLinkEvent notifies the channelEventNotifier goroutine that a +// link has been added to the switch. +func (c *ChannelNotifier) NotifyActiveLinkEvent(chanPoint wire.OutPoint) { + event := ActiveLinkEvent{ChannelPoint: &chanPoint} + if err := c.ntfnServer.SendUpdate(event); err != nil { + log.Warnf("Unable to send active link update: %v", err) + } +} + // NotifyActiveChannelEvent notifies the channelEventNotifier goroutine that a // channel is active. func (c *ChannelNotifier) NotifyActiveChannelEvent(chanPoint wire.OutPoint) {