From 07b46d5a054365b576b8dbab9744c944a4d6e4f4 Mon Sep 17 00:00:00 2001 From: Sam Kleinman Date: Thu, 17 Mar 2022 13:30:13 -0400 Subject: [PATCH] blocksync: drop redundant shutdown mechanisms (#8136) --- internal/blocksync/pool.go | 16 ---------------- internal/blocksync/reactor.go | 2 -- 2 files changed, 18 deletions(-) diff --git a/internal/blocksync/pool.go b/internal/blocksync/pool.go index 4c905c660..7f133a7a1 100644 --- a/internal/blocksync/pool.go +++ b/internal/blocksync/pool.go @@ -86,7 +86,6 @@ type BlockPool struct { requestsCh chan<- BlockRequest errorsCh chan<- peerError - exitedCh chan struct{} startHeight int64 lastHundredBlockTimeStamp time.Time @@ -109,7 +108,6 @@ func NewBlockPool( height: start, startHeight: start, numPending: 0, - exitedCh: make(chan struct{}), requestsCh: requestsCh, errorsCh: errorsCh, lastSyncRate: 0, @@ -125,11 +123,6 @@ func (pool *BlockPool) OnStart(ctx context.Context) error { pool.lastHundredBlockTimeStamp = pool.lastAdvance go pool.makeRequestersRoutine(ctx) - go func() { - defer close(pool.exitedCh) - pool.Wait() - }() - return nil } @@ -637,12 +630,6 @@ func (bpr *bpRequester) redo(peerID types.NodeID) { // Responsible for making more requests as necessary // Returns only when a block is found (e.g. AddBlock() is called) func (bpr *bpRequester) requestRoutine(ctx context.Context) { - bprPoolDone := make(chan struct{}) - go func() { - defer close(bprPoolDone) - bpr.pool.Wait() - }() - OUTER_LOOP: for { // Pick a peer to send request to. @@ -670,9 +657,6 @@ OUTER_LOOP: select { case <-ctx.Done(): return - case <-bpr.pool.exitedCh: - bpr.Stop() - return case peerID := <-bpr.redoCh: if peerID == bpr.peerID { bpr.reset() diff --git a/internal/blocksync/reactor.go b/internal/blocksync/reactor.go index cf1a10623..89c8c642b 100644 --- a/internal/blocksync/reactor.go +++ b/internal/blocksync/reactor.go @@ -445,8 +445,6 @@ func (r *Reactor) poolRoutine(ctx context.Context, stateSynced bool) { select { case <-ctx.Done(): return - case <-r.pool.exitedCh: - return case <-switchToConsensusTicker.C: var ( height, numPending, lenRequesters = r.pool.GetStatus()