Skip to content

Commit c0b4193

Browse files
committed
loopin: restore abandon chan on restart
1 parent 5e91c44 commit c0b4193

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

client.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,12 @@ func (s *Client) resumeSwaps(ctx context.Context,
381381
continue
382382
}
383383

384+
// Store the swap's abandon channel so that the client can
385+
// abandon the swap by providing the swap hash.
386+
s.executor.Lock()
387+
s.abandonChans[swap.hash] = swap.abandonChan
388+
s.executor.Unlock()
389+
384390
s.executor.initiateSwap(ctx, swap)
385391
}
386392
}

loopin.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,10 @@ func resumeLoopInSwap(_ context.Context, cfg *swapConfig,
421421
swap.cost = lastUpdate.Cost
422422
}
423423

424+
// Upon restoring the swap we also need to assign a new abandon channel
425+
// that the client can use to signal that the swap should be abandoned.
426+
swap.abandonChan = make(chan struct{}, 1)
427+
424428
return swap, nil
425429
}
426430

0 commit comments

Comments
 (0)