Skip to content

Commit

Permalink
fix(autoswap): use empty chanId as default when dismissing
Browse files Browse the repository at this point in the history
  • Loading branch information
jackstar12 committed Mar 14, 2024
1 parent 251dad7 commit 13f2d59
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
9 changes: 4 additions & 5 deletions autoswap/autoswap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -421,10 +421,9 @@ func TestDismissedChannels(t *testing.T) {
},
reverseSwaps: []database.ReverseSwap{
{
Id: "TEST",
State: boltzrpc.SwapState_PENDING,
IsAuto: true,
ChanIds: []lightning.ChanId{2},
Id: "TEST",
State: boltzrpc.SwapState_PENDING,
IsAuto: true,
},
{
Id: "TEST1",
Expand All @@ -434,8 +433,8 @@ func TestDismissedChannels(t *testing.T) {
},
},
dismissed: DismissedChannels{
0: []string{ReasonPendingSwap},
1: []string{ReasonPendingSwap},
2: []string{ReasonPendingSwap},
},
},
{
Expand Down
3 changes: 3 additions & 0 deletions autoswap/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ type DismissedChannels map[lightning.ChanId][]string
type ChannelLimits map[lightning.ChanId]uint64

func (dismissed DismissedChannels) addChannels(chanIds []lightning.ChanId, reason string) {
if chanIds == nil {
chanIds = []lightning.ChanId{0}
}
for _, chanId := range chanIds {
if !slices.Contains(dismissed[chanId], reason) {
dismissed[chanId] = append(dismissed[chanId], reason)
Expand Down

0 comments on commit 13f2d59

Please sign in to comment.