multi: move active/inactive ntfns from switch to link

Since we will now wait to deliver the event after channel reestablish,
notifying when the link is added to the switch will no longer be
sufficient. Later, we will add receiving reestablish as an additional
requirement for EligibleToForward returning true.

The inactive ntfn is also moved, to ensure that we don't fire inactive
notifications if no corresponding active notification was sent.
This commit is contained in:
Conner Fromknecht committed 2019-09-19 12:46:44 -07:00
1 parent 1d41d4d666
commit 6dca07577d
7 files changed
+28 -21

No files matched your search

-13
View File
@@ -163,11 +163,6 @@ type Config struct {
// fails in forwarding packages.
AckEventTicker ticker.Ticker
// NotifyActiveChannel and NotifyInactiveChannel allow the link to tell
// the ChannelNotifier when channels become active and inactive.
NotifyActiveChannel func(wire.OutPoint)
NotifyInactiveChannel func(wire.OutPoint)
// RejectHTLC is a flag that instructs the htlcswitch to reject any
// HTLCs that are not from the source hop.
RejectHTLC bool
@@ -2012,11 +2007,6 @@ func (s *Switch) addLiveLink(link ChannelLink) {
s.interfaceIndex[peerPub] = make(map[lnwire.ChannelID]ChannelLink)
}
s.interfaceIndex[peerPub][link.ChanID()] = link
// Inform the channel notifier if the link has become active.
if link.EligibleToForward() {
s.cfg.NotifyActiveChannel(*link.ChannelPoint())
}
}
// GetLink is used to initiate the handling of the get link command. The
@@ -2092,9 +2082,6 @@ func (s *Switch) removeLink(chanID lnwire.ChannelID) ChannelLink {
return nil
}
// Inform the Channel Notifier about the link becoming inactive.
s.cfg.NotifyInactiveChannel(*link.ChannelPoint())
// Remove the channel from live link indexes.
delete(s.pendingLinkIndex, link.ChanID())
delete(s.linkIndex, link.ChanID())