From 5ab69aedc74e7500846e61512c0892a5bd4b6976 Mon Sep 17 00:00:00 2001 From: Keagan McClelland Date: Sun, 26 Nov 2023 13:33:55 -0800 Subject: [PATCH] peer: remove tryLinkShutdown due to redundance We don't need to try a link shutdown when the chan closer is fetched since, by this commit, the only callsite manages the shutdown semantics. After removing the call to tryLinkShutdown, we no longer need the function at all. --- peer/brontide.go | 35 ----------------------------------- 1 file changed, 35 deletions(-) diff --git a/peer/brontide.go b/peer/brontide.go index fa8b53cc1..d362b1391 100644 --- a/peer/brontide.go +++ b/peer/brontide.go @@ -2575,12 +2575,6 @@ func (p *Brontide) fetchActiveChanCloser(chanID lnwire.ChannelID) ( return nil, ErrChannelNotFound } - // Optimistically try a link shutdown, erroring out if it failed. - if err := p.tryLinkShutdown(chanID); err != nil { - p.log.Errorf("failed link shutdown: %v", err) - return nil, err - } - // We'll create a valid closing state machine in order to respond to // the initiated cooperative channel closure. First, we set the // delivery script that our funds will be paid out to. If an upfront @@ -3114,35 +3108,6 @@ func (p *Brontide) handleLinkFailure(failure linkFailureReport) { } } -// tryLinkShutdown attempts to fetch a target link from the switch, calls -// ShutdownIfChannelClean to optimistically trigger a link shutdown, and -// removes the link from the switch. It returns an error if any step failed. -func (p *Brontide) tryLinkShutdown(cid lnwire.ChannelID) error { - // Fetch the appropriate link and call ShutdownIfChannelClean to ensure - // no other updates can occur. - chanLink := p.fetchLinkFromKeyAndCid(cid) - - // If the link happens to be nil, return ErrChannelNotFound so we can - // ignore the close message. - if chanLink == nil { - return ErrChannelNotFound - } - - // Else, the link exists, so attempt to trigger shutdown. If this - // fails, we'll send an error message to the remote peer. - if err := chanLink.ShutdownIfChannelClean(); err != nil { - return err - } - - // Next, we remove the link from the switch to shut down all of the - // link's goroutines and remove it from the switch's internal maps. We - // don't call WipeChannel as the channel must still be in the - // activeChannels map to process coop close messages. - p.cfg.Switch.RemoveLink(cid) - - return nil -} - // fetchLinkFromKeyAndCid fetches a link from the switch via the remote's // public key and the channel id. func (p *Brontide) fetchLinkFromKeyAndCid(