Browse Source

Merge branch 'master' into blocksync-avoid-redundant-channel

pull/8140/head
Sam Kleinman 3 years ago
committed by GitHub
parent
commit
98c72c7187
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 0 additions and 18 deletions
  1. +0
    -16
      internal/blocksync/pool.go
  2. +0
    -2
      internal/blocksync/reactor.go

+ 0
- 16
internal/blocksync/pool.go View File

@ -86,7 +86,6 @@ type BlockPool struct {
requestsCh chan<- BlockRequest requestsCh chan<- BlockRequest
errorsCh chan<- peerError errorsCh chan<- peerError
exitedCh chan struct{}
startHeight int64 startHeight int64
lastHundredBlockTimeStamp time.Time lastHundredBlockTimeStamp time.Time
@ -109,7 +108,6 @@ func NewBlockPool(
height: start, height: start,
startHeight: start, startHeight: start,
numPending: 0, numPending: 0,
exitedCh: make(chan struct{}),
requestsCh: requestsCh, requestsCh: requestsCh,
errorsCh: errorsCh, errorsCh: errorsCh,
lastSyncRate: 0, lastSyncRate: 0,
@ -125,11 +123,6 @@ func (pool *BlockPool) OnStart(ctx context.Context) error {
pool.lastHundredBlockTimeStamp = pool.lastAdvance pool.lastHundredBlockTimeStamp = pool.lastAdvance
go pool.makeRequestersRoutine(ctx) go pool.makeRequestersRoutine(ctx)
go func() {
defer close(pool.exitedCh)
pool.Wait()
}()
return nil return nil
} }
@ -637,12 +630,6 @@ func (bpr *bpRequester) redo(peerID types.NodeID) {
// Responsible for making more requests as necessary // Responsible for making more requests as necessary
// Returns only when a block is found (e.g. AddBlock() is called) // Returns only when a block is found (e.g. AddBlock() is called)
func (bpr *bpRequester) requestRoutine(ctx context.Context) { func (bpr *bpRequester) requestRoutine(ctx context.Context) {
bprPoolDone := make(chan struct{})
go func() {
defer close(bprPoolDone)
bpr.pool.Wait()
}()
OUTER_LOOP: OUTER_LOOP:
for { for {
// Pick a peer to send request to. // Pick a peer to send request to.
@ -670,9 +657,6 @@ OUTER_LOOP:
select { select {
case <-ctx.Done(): case <-ctx.Done():
return return
case <-bpr.pool.exitedCh:
bpr.Stop()
return
case peerID := <-bpr.redoCh: case peerID := <-bpr.redoCh:
if peerID == bpr.peerID { if peerID == bpr.peerID {
bpr.reset() bpr.reset()


+ 0
- 2
internal/blocksync/reactor.go View File

@ -427,8 +427,6 @@ func (r *Reactor) poolRoutine(ctx context.Context, stateSynced bool) {
select { select {
case <-ctx.Done(): case <-ctx.Done():
return return
case <-r.pool.exitedCh:
return
case <-switchToConsensusTicker.C: case <-switchToConsensusTicker.C:
var ( var (
height, numPending, lenRequesters = r.pool.GetStatus() height, numPending, lenRequesters = r.pool.GetStatus()


Loading…
Cancel
Save