diff --git a/eth/handler.go b/eth/handler.go index a0d5e990f..9704fc373 100644 --- a/eth/handler.go +++ b/eth/handler.go @@ -153,7 +153,6 @@ type handler struct { // channels for fetcher, syncer, txsyncLoop quitSync chan struct{} - stopCh chan struct{} chainSync *chainSyncer wg sync.WaitGroup @@ -182,7 +181,6 @@ func newHandler(config *handlerConfig) (*handler, error) { quitSync: make(chan struct{}), handlerDoneCh: make(chan struct{}), handlerStartCh: make(chan struct{}), - stopCh: make(chan struct{}), } if config.Sync == downloader.FullSync { // The database seems empty as the current block is the genesis. Yet the snap @@ -630,7 +628,6 @@ func (h *handler) Stop() { h.voteMonitorSub.Unsubscribe() } } - close(h.stopCh) // Quit chainSync and txsync64. // After this is done, no new peers will be accepted. close(h.quitSync) @@ -789,18 +786,10 @@ func (h *handler) BroadcastVote(vote *types.VoteEnvelope) { func (h *handler) minedBroadcastLoop() { defer h.wg.Done() - for { - select { - case obj := <-h.minedBlockSub.Chan(): - if obj == nil { - continue - } - if ev, ok := obj.Data.(core.NewMinedBlockEvent); ok { - h.BroadcastBlock(ev.Block, true) // First propagate block to peers - h.BroadcastBlock(ev.Block, false) // Only then announce to the rest - } - case <-h.stopCh: - return + for obj := range h.minedBlockSub.Chan() { + if ev, ok := obj.Data.(core.NewMinedBlockEvent); ok { + h.BroadcastBlock(ev.Block, true) // First propagate block to peers + h.BroadcastBlock(ev.Block, false) // Only then announce to the rest } } } @@ -814,8 +803,6 @@ func (h *handler) txBroadcastLoop() { h.BroadcastTransactions(event.Txs) case <-h.txsSub.Err(): return - case <-h.stopCh: - return } } } @@ -831,8 +818,6 @@ func (h *handler) voteBroadcastLoop() { h.BroadcastVote(event.Vote) case <-h.votesSub.Err(): return - case <-h.stopCh: - return } } } @@ -848,8 +833,6 @@ func (h *handler) startMaliciousVoteMonitor() { h.maliciousVoteMonitor.ConflictDetect(event.Vote, pendingBlockNumber) case <-h.voteMonitorSub.Err(): return - case <-h.stopCh: - return } } }