code: func (ps *peerSet) idlePeers(minProtocol, maxProtocol int, idleCheck func(*peerConnection) bool, throughput func(*peerConnection) float64) ([]*peerConnection, int) {
  	ps.lock.RLock()
  	defer ps.lock.RUnlock()
  
  	idle, total := make([]*peerConnection, 0, len(ps.peers)), 0
  	for _, p := range ps.peers {
  		if p.version >= minProtocol && p.version <= maxProtocol {
  			if idleCheck(p) {
  				idle = append(idle, p)
  			}
  			total++
  		}
  	}
  	for i := 0; i < len(idle); i++ {
  		for j := i + 1; j < len(idle); j++ {
  			if throughput(idle[i]) < throughput(idle[j]) {
  				idle[i], idle[j] = idle[j], idle[i]
  			}
  		}
  	}
  	return idle, total
  }
docs: // idlePeers retrieves a flat list of all currently idle peers satisfying the
  // protocol version constraints, using the provided function to check idleness.
  // The resulting set of peers are sorted by their measure throughput.