Skip to content

Commit

Permalink
close channel if subscription fails
Browse files Browse the repository at this point in the history
  • Loading branch information
vgonkivs committed Feb 7, 2025
1 parent b616d20 commit 2771226
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions core/fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,17 +169,17 @@ func (f *BlockFetcher) SubscribeNewBlockEvent(ctx context.Context) (<-chan types
}
ctx, cancel := context.WithCancel(ctx)
f.cancel = cancel
f.doneCh = make(chan struct{})
f.isListeningForBlocks.Store(true)

subscription, err := f.client.SubscribeNewHeights(ctx, &coregrpc.SubscribeNewHeightsRequest{})
if err != nil {
close(f.doneCh)
f.isListeningForBlocks.Store(false)
return nil, err
}

log.Debug("created a subscription. Start listening for new blocks...")

f.doneCh = make(chan struct{})
signedBlockCh := make(chan types.EventDataSignedBlock)
go func() {
defer close(f.doneCh)
Expand Down

0 comments on commit 2771226

Please sign in to comment.