Improve rarest-first behavior by not favoring a partial piece

held by multiple peers when requesting from a seed
This commit is contained in:
zzz
2012-05-30 15:21:37 +00:00
parent c6fcdf967c
commit 8453c34bfc
2 changed files with 24 additions and 3 deletions

View File

@@ -57,6 +57,15 @@ class Piece implements Comparable {
/** caller must synchronize */
public boolean removePeer(Peer peer) { return this.peers.remove(peer.getPeerID()); }
/**
* How many peers have this piece?
* Caller must synchronize
* @since 0.9.1
*/
public int getPeerCount() {
return this.peers.size();
}
/** caller must synchronize */
public boolean isRequested() {
return this.requests != null && !this.requests.isEmpty();