Actually, each peer will connect with a subset of the entire swarm. When a given peer reaches maximum swarm size[1] it will ignore future connections.
Inside the swarm, a peer will select contributors[2] according to their score[3]:
- When connect with other peer, you calculate the RTT [4] between you and the other and decreases the score according to it
- When you receive `contain` instruction from a peer, you add 1 to the score
- When you receive `satisfy` instruction from a peer, you add 1 to the score
- When you receive `choke` instruction, you decrease 1
This way, your swarm array is ordered according to this algorithm. Peers with small RTT and sending contain (have the chunks you want) will have higher scores and will stay on the head of the ordered array, being promoted as partner and contributing to the overlay.