lnwallet: use fn.Set API directly instead of empty struct map.

This commit is contained in:
Keagan McClelland committed 2024-10-14 09:33:38 -06:00
1 parent d82d02831d
commit b902d0825d
1 file changed
+6 -6
+6 -6
View File
@@ -2911,8 +2911,8 @@ func (lc *LightningChannel) evaluateHTLCView(view *HtlcView, ourBalance,
// keep track of which entries we need to skip when creating the final
// htlc view. We skip an entry whenever we find a settle or a timeout
// modifying an entry.
skipUs := make(map[uint64]struct{})
skipThem := make(map[uint64]struct{})
skipUs := fn.NewSet[uint64]()
skipThem := fn.NewSet[uint64]()
// First we run through non-add entries in both logs, populating the
// skip sets.
@@ -2947,7 +2947,7 @@ func (lc *LightningChannel) evaluateHTLCView(view *HtlcView, ourBalance,
return nil, lntypes.Dual[[]*paymentDescriptor]{}, err
}
skipThem[addEntry.HtlcIndex] = struct{}{}
skipThem.Add(addEntry.HtlcIndex)
rmvHeight := entry.removeCommitHeights.GetForParty(
whoseCommitChain,
@@ -2991,7 +2991,7 @@ func (lc *LightningChannel) evaluateHTLCView(view *HtlcView, ourBalance,
return nil, lntypes.Dual[[]*paymentDescriptor]{}, err
}
skipUs[addEntry.HtlcIndex] = struct{}{}
skipUs.Add(addEntry.HtlcIndex)
rmvHeight := entry.removeCommitHeights.GetForParty(
whoseCommitChain,
@@ -3008,7 +3008,7 @@ func (lc *LightningChannel) evaluateHTLCView(view *HtlcView, ourBalance,
// added HTLCs.
for _, entry := range view.OurUpdates {
isAdd := entry.EntryType == Add
if _, ok := skipUs[entry.HtlcIndex]; !isAdd || ok {
if skipUs.Contains(entry.HtlcIndex) || !isAdd {
continue
}
@@ -3029,7 +3029,7 @@ func (lc *LightningChannel) evaluateHTLCView(view *HtlcView, ourBalance,
// Again, we do the same for our peer's updates.
for _, entry := range view.TheirUpdates {
isAdd := entry.EntryType == Add
if _, ok := skipThem[entry.HtlcIndex]; !isAdd || ok {
if skipThem.Contains(entry.HtlcIndex) || !isAdd {
continue
}