From 6feed32288acb8a00cadcad665fd62209baf0320 Mon Sep 17 00:00:00 2001 From: ziggie Date: Fri, 6 Jun 2025 13:27:22 +0200 Subject: [PATCH] htlcswitch: exit early if no adds are in the fwd pkg This lead to the case that we would always record a HTLC two times in the decayed log protection which is not necessary in the first place. --- htlcswitch/link.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/htlcswitch/link.go b/htlcswitch/link.go index f14abd9ab..72b506986 100644 --- a/htlcswitch/link.go +++ b/htlcswitch/link.go @@ -3624,6 +3624,9 @@ func (l *channelLink) updateChannelFee(ctx context.Context, // the switch. func (l *channelLink) processRemoteSettleFails(fwdPkg *channeldb.FwdPkg) { if len(fwdPkg.SettleFails) == 0 { + l.log.Trace("fwd package has no settle/fails to process " + + "exiting early") + return } @@ -3728,6 +3731,13 @@ func (l *channelLink) processRemoteSettleFails(fwdPkg *channeldb.FwdPkg) { // //nolint:funlen func (l *channelLink) processRemoteAdds(fwdPkg *channeldb.FwdPkg) { + // Exit early if there are no adds to process. + if len(fwdPkg.Adds) == 0 { + l.log.Trace("fwd package has no adds to process exiting early") + + return + } + l.log.Tracef("processing %d remote adds for height %d", len(fwdPkg.Adds), fwdPkg.Height)