lnwallet: pack paymentDescriptor add/remove heights into Duals

The purpose of this commit is to begin the process of packing
symmetric fields into the newly introduced Dual structure. The
reason for this is that the Dual structure has a handy indexing
method where we can supply a ChannelParty and get back a value.
This will cut down on the amount of branching code in the main
lines of the codebase logic, making it easier to follow what is
going on.
This commit is contained in:
Keagan McClelland committed 2024-10-11 11:10:37 +02:00
1 parent 0dd58ee529
commit b457b40f80
5 files changed
+301 -224

No files matched your search

+4 -5
View File
@@ -153,6 +153,7 @@ func compactLogs(ourLog, theirLog *updateLog,
nextA = e.Next()
htlc := e.Value
rmvHeights := htlc.removeCommitHeights
// We skip Adds, as they will be removed along with the
// fail/settles below.
@@ -162,9 +163,7 @@ func compactLogs(ourLog, theirLog *updateLog,
// If the HTLC hasn't yet been removed from either
// chain, the skip it.
if htlc.removeCommitHeightRemote == 0 ||
htlc.removeCommitHeightLocal == 0 {
if rmvHeights.Remote == 0 || rmvHeights.Local == 0 {
continue
}
@@ -172,8 +171,8 @@ func compactLogs(ourLog, theirLog *updateLog,
// is at least the height in which the HTLC was
// removed, then evict the settle/timeout entry along
// with the original add entry.
if remoteChainTail >= htlc.removeCommitHeightRemote &&
localChainTail >= htlc.removeCommitHeightLocal {
if remoteChainTail >= rmvHeights.Remote &&
localChainTail >= rmvHeights.Local {
// Fee updates have no parent htlcs, so we only
// remove the update itself.