From 277949cb0e08095091a6a56c44d34d553a4d02d1 Mon Sep 17 00:00:00 2001 From: "Johan T. Halseth" Date: Thu, 10 Jan 2019 12:23:57 +0100 Subject: [PATCH] lnwallet/channel: remove FeeUpdates when compacting logs When compacting the update logs we remove any fee updates when they remove height is passed. We do this since we'll assume fee updates are added and removed at the same commit height, as they will apply for all commitments following the fee update. --- lnwallet/channel.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lnwallet/channel.go b/lnwallet/channel.go index 7911d4ac..8d3d25ff 100644 --- a/lnwallet/channel.go +++ b/lnwallet/channel.go @@ -1211,6 +1211,9 @@ func compactLogs(ourLog, theirLog *updateLog, nextA = e.Next() htlc := e.Value.(*PaymentDescriptor) + + // We skip Adds, as they will be removed along with the + // fail/settles below. if htlc.EntryType == Add { continue } @@ -1229,6 +1232,16 @@ func compactLogs(ourLog, theirLog *updateLog, if remoteChainTail >= htlc.removeCommitHeightRemote && localChainTail >= htlc.removeCommitHeightLocal { + // Fee updates have no parent htlcs, so we only + // remove the update itself. + if htlc.EntryType == FeeUpdate { + logA.removeUpdate(htlc.LogIndex) + continue + } + + // The other types (fail/settle) do have a + // parent HTLC, so we'll remove that HTLC from + // the other log. logA.removeUpdate(htlc.LogIndex) logB.removeHtlc(htlc.ParentIndex) }