htlcswitch: notify channel active after reforwarding

The channel should only be considered active when its pending tasks are
finished, which includes,
1. sync channel state via reestablish.
2. send previous shutdown msg.
3. reset the mailbox's packets.
4. reforwarding logs loaded from restart.

When the above tasks are finished, the channel can be considered as
fully resumed from its previous disconnection.
This commit is contained in:
yyforyongyu
2025-06-30 20:56:50 +08:00
parent 09022b5f56
commit ca770bb4af

View File

@@ -1307,13 +1307,6 @@ func (l *channelLink) htlcManager(ctx context.Context) {
// allow the switch to forward HTLCs in the outbound direction.
l.markReestablished()
// Now that we've received both channel_ready and channel reestablish,
// we can go ahead and send the active channel notification. We'll also
// defer the inactive notification for when the link exits to ensure
// that every active notification is matched by an inactive one.
l.cfg.NotifyActiveChannel(l.ChannelPoint())
defer l.cfg.NotifyInactiveChannel(l.ChannelPoint())
// With the channel states synced, we now reset the mailbox to ensure
// we start processing all unacked packets in order. This is done here
// to ensure that all acknowledgments that occur during channel
@@ -1355,6 +1348,13 @@ func (l *channelLink) htlcManager(ctx context.Context) {
go l.fwdPkgGarbager()
}
// Now that we've received both channel_ready and channel reestablish,
// we can go ahead and send the active channel notification. We'll also
// defer the inactive notification for when the link exits to ensure
// that every active notification is matched by an inactive one.
l.cfg.NotifyActiveChannel(l.ChannelPoint())
defer l.cfg.NotifyInactiveChannel(l.ChannelPoint())
for {
// We must always check if we failed at some point processing
// the last update before processing the next.