Skip to content

Commit

Permalink
Fix: merge swaps
Browse files Browse the repository at this point in the history
  • Loading branch information
aopoltorzhicky committed Jan 20, 2022
1 parent f8f4458 commit f03b1b7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions cmd/watch_tower/swap.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,11 @@ func (swap *Swap) Leg() *tools.Leg {
}
return nil
}

func (swap *Swap) merge(update tools.Swap) {
if update.HashedSecret.String() != swap.HashedSecret.String() || update.Status < swap.Status {
return
}

swap.Swap = update
}
2 changes: 1 addition & 1 deletion cmd/watch_tower/watch_tower.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func (wt *WatchTower) listen(ctx context.Context) {
s = &Swap{swap, 0}
wt.swaps[swap.HashedSecret] = s
} else {
s.Swap = swap
s.merge(swap)
}

if err := wt.onSwap(ctx, s); err != nil {
Expand Down

0 comments on commit f03b1b7

Please sign in to comment.