Close channels in the correct location
This commit is contained in:
parent
9664783eef
commit
32ec784e1e
@ -39,6 +39,8 @@ func (bc *BeaconClient) StopHeadTracking(ctx context.Context, skipSee bool) {
|
|||||||
bc.HeadTracking.SseClient.Unsubscribe(bc.HeadTracking.MessagesCh)
|
bc.HeadTracking.SseClient.Unsubscribe(bc.HeadTracking.MessagesCh)
|
||||||
bc.ReOrgTracking.SseClient.Unsubscribe(bc.ReOrgTracking.MessagesCh)
|
bc.ReOrgTracking.SseClient.Unsubscribe(bc.ReOrgTracking.MessagesCh)
|
||||||
log.Info("Successfully unsubscribed to SSE client")
|
log.Info("Successfully unsubscribed to SSE client")
|
||||||
|
close(bc.ReOrgTracking.MessagesCh)
|
||||||
|
close(bc.HeadTracking.MessagesCh)
|
||||||
}
|
}
|
||||||
log.Info("Successfully stopped the head tracking service.")
|
log.Info("Successfully stopped the head tracking service.")
|
||||||
default:
|
default:
|
||||||
|
@ -47,8 +47,7 @@ func handleIncomingSseEvent[P ProcessedEvents](ctx context.Context, eventHandler
|
|||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
close(eventHandler.MessagesCh)
|
close(eventHandler.ProcessCh)
|
||||||
close(eventHandler.ErrorCh)
|
|
||||||
return
|
return
|
||||||
case message := <-eventHandler.MessagesCh:
|
case message := <-eventHandler.MessagesCh:
|
||||||
// Message can be nil if its a keep-alive message
|
// Message can be nil if its a keep-alive message
|
||||||
|
@ -33,7 +33,6 @@ func (bc *BeaconClient) handleReorg(ctx context.Context) {
|
|||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
close(bc.ReOrgTracking.ProcessCh)
|
|
||||||
return
|
return
|
||||||
case reorg := <-bc.ReOrgTracking.ProcessCh:
|
case reorg := <-bc.ReOrgTracking.ProcessCh:
|
||||||
log.WithFields(log.Fields{"reorg": reorg}).Debug("Received a new reorg message.")
|
log.WithFields(log.Fields{"reorg": reorg}).Debug("Received a new reorg message.")
|
||||||
@ -55,7 +54,6 @@ func (bc *BeaconClient) handleHead(ctx context.Context, maxWorkers int) {
|
|||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
close(bc.HeadTracking.ProcessCh)
|
|
||||||
close(workCh)
|
close(workCh)
|
||||||
return
|
return
|
||||||
case head := <-bc.HeadTracking.ProcessCh:
|
case head := <-bc.HeadTracking.ProcessCh:
|
||||||
|
Loading…
Reference in New Issue
Block a user