diff --git a/cmd/watch_tower/swap.go b/cmd/watch_tower/swap.go index 58672cd..cec6162 100644 --- a/cmd/watch_tower/swap.go +++ b/cmd/watch_tower/swap.go @@ -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 +} diff --git a/cmd/watch_tower/watch_tower.go b/cmd/watch_tower/watch_tower.go index e7f11b4..fe87243 100644 --- a/cmd/watch_tower/watch_tower.go +++ b/cmd/watch_tower/watch_tower.go @@ -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 {