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.
This commit is contained in:
Johan T. Halseth 2019-01-10 12:23:57 +01:00
parent 480f43f1dc
commit 277949cb0e
No known key found for this signature in database
GPG Key ID: 15BAADA29DA20D26

@ -1211,6 +1211,9 @@ func compactLogs(ourLog, theirLog *updateLog,
nextA = e.Next() nextA = e.Next()
htlc := e.Value.(*PaymentDescriptor) htlc := e.Value.(*PaymentDescriptor)
// We skip Adds, as they will be removed along with the
// fail/settles below.
if htlc.EntryType == Add { if htlc.EntryType == Add {
continue continue
} }
@ -1229,6 +1232,16 @@ func compactLogs(ourLog, theirLog *updateLog,
if remoteChainTail >= htlc.removeCommitHeightRemote && if remoteChainTail >= htlc.removeCommitHeightRemote &&
localChainTail >= htlc.removeCommitHeightLocal { 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) logA.removeUpdate(htlc.LogIndex)
logB.removeHtlc(htlc.ParentIndex) logB.removeHtlc(htlc.ParentIndex)
} }