htlcswitch+peer: notify inactive link event when htlcManager exits
This commit is contained in:
5 files changed
+15
-1
No files matched your search
+8
-1
@@ -293,6 +293,10 @@ type ChannelLinkConfig struct {
|
|||||||
// when channels become inactive.
|
// when channels become inactive.
|
||||||
NotifyInactiveChannel func(wire.OutPoint)
|
NotifyInactiveChannel func(wire.OutPoint)
|
||||||
|
|
||||||
|
// NotifyInactiveLinkEvent allows the switch to tell the
|
||||||
|
// ChannelNotifier when a channel link become inactive.
|
||||||
|
NotifyInactiveLinkEvent func(wire.OutPoint)
|
||||||
|
|
||||||
// HtlcNotifier is an instance of a htlcNotifier which we will pipe htlc
|
// HtlcNotifier is an instance of a htlcNotifier which we will pipe htlc
|
||||||
// events through.
|
// events through.
|
||||||
HtlcNotifier htlcNotifier
|
HtlcNotifier htlcNotifier
|
||||||
@@ -979,8 +983,11 @@ func (l *channelLink) htlcManager() {
|
|||||||
l.log.Infof("HTLC manager started, bandwidth=%v", l.Bandwidth())
|
l.log.Infof("HTLC manager started, bandwidth=%v", l.Bandwidth())
|
||||||
|
|
||||||
// Notify any clients that the link is now in the switch via an
|
// Notify any clients that the link is now in the switch via an
|
||||||
// ActiveLinkEvent.
|
// ActiveLinkEvent. We'll also defer an inactive link notification for
|
||||||
|
// when the link exits to ensure that every active notification is
|
||||||
|
// matched by an inactive one.
|
||||||
l.cfg.NotifyActiveLink(*l.ChannelPoint())
|
l.cfg.NotifyActiveLink(*l.ChannelPoint())
|
||||||
|
defer l.cfg.NotifyInactiveLinkEvent(*l.ChannelPoint())
|
||||||
|
|
||||||
// TODO(roasbeef): need to call wipe chan whenever D/C?
|
// TODO(roasbeef): need to call wipe chan whenever D/C?
|
||||||
|
|
||||||
|
|||||||
@@ -1894,6 +1894,7 @@ func newSingleLinkTestHarness(t *testing.T, chanAmt, chanReserve btcutil.Amount)
|
|||||||
NotifyActiveLink: func(wire.OutPoint) {},
|
NotifyActiveLink: func(wire.OutPoint) {},
|
||||||
NotifyActiveChannel: func(wire.OutPoint) {},
|
NotifyActiveChannel: func(wire.OutPoint) {},
|
||||||
NotifyInactiveChannel: func(wire.OutPoint) {},
|
NotifyInactiveChannel: func(wire.OutPoint) {},
|
||||||
|
NotifyInactiveLinkEvent: func(wire.OutPoint) {},
|
||||||
HtlcNotifier: aliceSwitch.cfg.HtlcNotifier,
|
HtlcNotifier: aliceSwitch.cfg.HtlcNotifier,
|
||||||
GetAliases: getAliases,
|
GetAliases: getAliases,
|
||||||
}
|
}
|
||||||
@@ -4335,6 +4336,7 @@ func (h *persistentLinkHarness) restartLink(
|
|||||||
NotifyActiveLink: func(wire.OutPoint) {},
|
NotifyActiveLink: func(wire.OutPoint) {},
|
||||||
NotifyActiveChannel: func(wire.OutPoint) {},
|
NotifyActiveChannel: func(wire.OutPoint) {},
|
||||||
NotifyInactiveChannel: func(wire.OutPoint) {},
|
NotifyInactiveChannel: func(wire.OutPoint) {},
|
||||||
|
NotifyInactiveLinkEvent: func(wire.OutPoint) {},
|
||||||
HtlcNotifier: aliceSwitch.cfg.HtlcNotifier,
|
HtlcNotifier: aliceSwitch.cfg.HtlcNotifier,
|
||||||
SyncStates: syncStates,
|
SyncStates: syncStates,
|
||||||
GetAliases: getAliases,
|
GetAliases: getAliases,
|
||||||
|
|||||||
@@ -2293,6 +2293,8 @@ func (s *Switch) AddLink(link ChannelLink) error {
|
|||||||
link.attachFailAliasUpdate(s.failAliasUpdate)
|
link.attachFailAliasUpdate(s.failAliasUpdate)
|
||||||
|
|
||||||
if err := link.Start(); err != nil {
|
if err := link.Start(); err != nil {
|
||||||
|
log.Errorf("AddLink failed to start link with chanID=%v: %v",
|
||||||
|
chanID, err)
|
||||||
s.removeLink(chanID)
|
s.removeLink(chanID)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1159,6 +1159,7 @@ func (h *hopNetwork) createChannelLink(server, peer *mockServer,
|
|||||||
NotifyActiveLink: func(wire.OutPoint) {},
|
NotifyActiveLink: func(wire.OutPoint) {},
|
||||||
NotifyActiveChannel: func(wire.OutPoint) {},
|
NotifyActiveChannel: func(wire.OutPoint) {},
|
||||||
NotifyInactiveChannel: func(wire.OutPoint) {},
|
NotifyInactiveChannel: func(wire.OutPoint) {},
|
||||||
|
NotifyInactiveLinkEvent: func(wire.OutPoint) {},
|
||||||
HtlcNotifier: server.htlcSwitch.cfg.HtlcNotifier,
|
HtlcNotifier: server.htlcSwitch.cfg.HtlcNotifier,
|
||||||
GetAliases: getAliases,
|
GetAliases: getAliases,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -941,6 +941,7 @@ func (p *Brontide) addLink(chanPoint *wire.OutPoint,
|
|||||||
towerClient = p.cfg.TowerClient
|
towerClient = p.cfg.TowerClient
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//nolint:lll
|
||||||
linkCfg := htlcswitch.ChannelLinkConfig{
|
linkCfg := htlcswitch.ChannelLinkConfig{
|
||||||
Peer: p,
|
Peer: p,
|
||||||
DecodeHopIterators: p.cfg.Sphinx.DecodeHopIterators,
|
DecodeHopIterators: p.cfg.Sphinx.DecodeHopIterators,
|
||||||
@@ -976,6 +977,7 @@ func (p *Brontide) addLink(chanPoint *wire.OutPoint,
|
|||||||
NotifyActiveLink: p.cfg.ChannelNotifier.NotifyActiveLinkEvent,
|
NotifyActiveLink: p.cfg.ChannelNotifier.NotifyActiveLinkEvent,
|
||||||
NotifyActiveChannel: p.cfg.ChannelNotifier.NotifyActiveChannelEvent,
|
NotifyActiveChannel: p.cfg.ChannelNotifier.NotifyActiveChannelEvent,
|
||||||
NotifyInactiveChannel: p.cfg.ChannelNotifier.NotifyInactiveChannelEvent,
|
NotifyInactiveChannel: p.cfg.ChannelNotifier.NotifyInactiveChannelEvent,
|
||||||
|
NotifyInactiveLinkEvent: p.cfg.ChannelNotifier.NotifyInactiveLinkEvent,
|
||||||
HtlcNotifier: p.cfg.HtlcNotifier,
|
HtlcNotifier: p.cfg.HtlcNotifier,
|
||||||
GetAliases: p.cfg.GetAliases,
|
GetAliases: p.cfg.GetAliases,
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user