I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit 8458e4e0 authored by ragnarok's avatar ragnarok Committed by zzz
Browse files

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

parent 0b9e4967
No related branches found
No related tags found
No related merge requests found
...@@ -511,6 +511,12 @@ public class PeerCoordinator implements PeerListener ...@@ -511,6 +511,12 @@ public class PeerCoordinator implements PeerListener
{ {
// Unchoke some random other peer // Unchoke some random other peer
unchokePeer(); 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 { ...@@ -31,6 +31,7 @@ public class Piece implements Comparable {
public int getId() { return this.id; } public int getId() { return this.id; }
public Set getPeers() { return this.peers; } public Set getPeers() { return this.peers; }
public boolean addPeer(Peer peer) { return this.peers.add(peer.getPeerID()); } 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 boolean isRequested() { return this.requested; }
public void setRequested(boolean requested) { this.requested = requested; } public void setRequested(boolean requested) { this.requested = requested; }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment