code: func (q *queue) resultSlots(pendPool map[string]*fetchRequest, donePool map[common.Hash]struct{}) int {
  	// Calculate the maximum length capped by the memory limit
  	limit := len(q.resultCache)
  	if common.StorageSize(len(q.resultCache))*q.resultSize > common.StorageSize(blockCacheMemory) {
  		limit = int((common.StorageSize(blockCacheMemory) + q.resultSize - 1) / q.resultSize)
  	}
  	// Calculate the number of slots already finished
  	finished := 0
  	for _, result := range q.resultCache[:limit] {
  		if result == nil {
  			break
  		}
  		if _, ok := donePool[result.Hash]; ok {
  			finished++
  		}
  	}
  	// Calculate the number of slots currently downloading
  	pending := 0
  	for _, request := range pendPool {
  		for _, header := range request.Headers {
  			if header.Number.Uint64() < q.resultOffset+uint64(limit) {
  				pending++
  			}
  		}
  	}
  	// Return the free slots to distribute
  	return limit - finished - pending
  }
docs: // resultSlots calculates the number of results slots available for requests
  // whilst adhering to both the item and the memory limit too of the results
  // cache.