mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-13 12:33:03 +02:00
reservations: check if channel is closing
This commit adds a check to the runtime loop of the reservation manager to check if the channel is closing before trying to read from it.
This commit is contained in:
parent
2c32575c75
commit
d6c7237b77
1 changed files with 9 additions and 2 deletions
|
|
@ -56,7 +56,7 @@ func (m *Manager) Run(ctx context.Context, height int32) error {
|
|||
return err
|
||||
}
|
||||
|
||||
ntfnChan := m.cfg.NotificationManager.SubscribeReservations(ctx)
|
||||
ntfnChan := m.cfg.NotificationManager.SubscribeReservations(runCtx)
|
||||
|
||||
for {
|
||||
select {
|
||||
|
|
@ -64,7 +64,14 @@ func (m *Manager) Run(ctx context.Context, height int32) error {
|
|||
log.Debugf("Received block %v", height)
|
||||
currentHeight = height
|
||||
|
||||
case reservationRes := <-ntfnChan:
|
||||
case reservationRes, ok := <-ntfnChan:
|
||||
if !ok {
|
||||
// The channel has been closed, we'll stop the
|
||||
// reservation manager.
|
||||
log.Debugf("Stopping reservation manager (ntfnChan closed)")
|
||||
return nil
|
||||
}
|
||||
|
||||
log.Debugf("Received reservation %x",
|
||||
reservationRes.ReservationId)
|
||||
_, err := m.newReservation(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue