code: func (s *scheduler) scheduleRequests(reqs chan uint64, dist chan *request, pend chan uint64, quit chan struct{}, wg *sync.WaitGroup) {
  	// Clean up the goroutine and pipeline when done
  	defer wg.Done()
  	defer close(pend)
  
  	// Keep reading and scheduling section requests
  	for {
  		select {
  		case <-quit:
  			return
  
  		case section, ok := <-reqs:
  			// New section retrieval requested
  			if !ok {
  				return
  			}
  			// Deduplicate retrieval requests
  			unique := false
  
  			s.lock.Lock()
  			if s.responses[section] == nil {
  				s.responses[section] = &response{
  					done: make(chan struct{}),
  				}
  				unique = true
  			}
  			s.lock.Unlock()
  
  			// Schedule the section for retrieval and notify the deliverer to expect this section
  			if unique {
  				select {
  				case <-quit:
  					return
  				case dist <- &request{bit: s.bit, section: section}:
  				}
  			}
  			select {
  			case <-quit:
  				return
  			case pend <- section:
  			}
  		}
  	}
  }
docs: // scheduleRequests reads section retrieval requests from the input channel,
  // deduplicates the stream and pushes unique retrieval tasks into the distribution
  // channel for a database or network layer to honour.