Don't count peers we can't connect to for rarest-first calculations.

This commit is contained in:
ragnarok
2005-10-20 23:28:32 +00:00
committed by zzz
parent 0b9e4967a0
commit 8458e4e0af
2 changed files with 7 additions and 0 deletions

View File

@ -511,6 +511,12 @@ public class PeerCoordinator implements PeerListener
{
// Unchoke some random other peer
unchokePeer();
// Don't count disconnected peers for the rarest-first calculations
for(Iterator iter = wantedPieces.iterator(); iter.hasNext(); ) {
Piece piece = (Piece)iter.next();
piece.removePeer(peer);
}
}
}

View File

@ -31,6 +31,7 @@ public class Piece implements Comparable {
public int getId() { return this.id; }
public Set getPeers() { return this.peers; }
public boolean addPeer(Peer peer) { return this.peers.add(peer.getPeerID()); }
public boolean removePeer(Peer peer) { return this.peers.remove(peer.getPeerID()); }
public boolean isRequested() { return this.requested; }
public void setRequested(boolean requested) { this.requested = requested; }
}