From 637354f037e53165c5e7aa8c266be0b13de143e1 Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Tue, 23 Jun 2020 18:50:52 -0500 Subject: [PATCH] QSP-42 Remove Double Unsubscribe in Initial Sync (#6368) * rem double unsub * Update beacon-chain/sync/initial-sync/service.go Co-authored-by: Preston Van Loon * Merge refs/heads/master into qsp-unsub * Merge refs/heads/master into qsp-unsub * Merge refs/heads/master into qsp-unsub * Merge refs/heads/master into qsp-unsub * Merge refs/heads/master into qsp-unsub --- beacon-chain/sync/initial-sync/service.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/beacon-chain/sync/initial-sync/service.go b/beacon-chain/sync/initial-sync/service.go index 6f8877db2..d25ef8400 100644 --- a/beacon-chain/sync/initial-sync/service.go +++ b/beacon-chain/sync/initial-sync/service.go @@ -80,9 +80,7 @@ func (s *Service) Start() { // Wait for state to be initialized. stateChannel := make(chan *feed.Event, 1) stateSub := s.stateNotifier.StateFeed().Subscribe(stateChannel) - defer stateSub.Unsubscribe() - genesisSet := false - for !genesisSet { + for genesisSet := false; !genesisSet; { select { case event := <-stateChannel: if event.Type == statefeed.Initialized { @@ -97,10 +95,10 @@ func (s *Service) Start() { } case <-s.ctx.Done(): log.Debug("Context closed, exiting goroutine") - return + break case err := <-stateSub.Err(): log.WithError(err).Error("Subscription to state notifier failed") - return + break } } stateSub.Unsubscribe()