Don't count peers we can't connect to for rarest-first calculations.
This commit is contained in:
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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; }
|
||||
}
|
||||
|
Reference in New Issue
Block a user