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

Skip to content
Snippets Groups Projects
Commit c1a8c8a3 authored by zzz's avatar zzz
Browse files

propagate from branch 'i2p.i2p.zzz.test' (head ff346bd41de699648bb66488ec9c0f1f4b5300b1)

            to branch 'i2p.i2p' (head 2914d3356f892de25a745f061129704f8b943fc5)
parents 45d9f9d0 4975d307
No related branches found
No related tags found
No related merge requests found
...@@ -379,34 +379,30 @@ public class ProfileOrganizer { ...@@ -379,34 +379,30 @@ public class ProfileOrganizer {
* Return a set of Hashes for peers that are both not failing and we're actively * Return a set of Hashes for peers that are both not failing and we're actively
* talking with. * talking with.
* *
* We use commSystem().isEstablished(), not profile.getIsActive(), as the
* NTCP idle time is now shorter than the 5 minute getIsActive() threshold,
* and we're using this to try and limit connections.
*
* Caution, this does NOT cascade further to non-connected peers, so it should only
* be used when there is a good number of connected peers.
*
* @param exclude non-null
* No mask parameter, to be fixed
*/ */
/* public void selectActiveNotFailingPeers(int howMany, Set exclude, Set matches) {
private void selectActiveNotFailingPeers(int howMany, Set exclude, Set matches) {
if (true) {
selectAllNotFailingPeers(howMany, exclude, matches);
return;
}
// pick out the not-failing peers that we're actively talking with
if (matches.size() < howMany) { if (matches.size() < howMany) {
synchronized (_reorganizeLock) { getReadLock();
for (Iterator iter = _notFailingPeers.keySet().iterator(); iter.hasNext(); ) { try {
Hash peer = (Hash)iter.next(); for (Iterator<Hash> iter = _notFailingPeers.keySet().iterator(); iter.hasNext(); ) {
if ( (exclude != null) && exclude.contains(peer) ) continue; Hash peer = iter.next();
if (matches.contains(peer)) continue; if (!_context.commSystem().isEstablished(peer))
PeerProfile prof = (PeerProfile)_notFailingPeers.get(peer); exclude.add(peer);
if (prof.getIsActive())
matches.add(peer);
if (matches.size() >= howMany)
return;
} }
} locked_selectPeers(_notFailingPeers, howMany, exclude, matches, 0);
} finally { releaseReadLock(); }
} }
// ok, still not enough, pick out the not-failing peers that we aren't talking with
if (matches.size() < howMany)
selectAllNotFailingPeers(howMany, exclude, matches);
return;
} }
*/
/** /**
* Return a set of Hashes for peers that are not failing. * Return a set of Hashes for peers that are not failing.
* *
...@@ -414,6 +410,10 @@ public class ProfileOrganizer { ...@@ -414,6 +410,10 @@ public class ProfileOrganizer {
public void selectAllNotFailingPeers(int howMany, Set exclude, Set matches, boolean onlyNotFailing) { public void selectAllNotFailingPeers(int howMany, Set exclude, Set matches, boolean onlyNotFailing) {
selectAllNotFailingPeers(howMany, exclude, matches, onlyNotFailing, 0); selectAllNotFailingPeers(howMany, exclude, matches, onlyNotFailing, 0);
} }
/**
* @param mask ignored, should call locked_selectPeers, to be fixed
*
*/
private void selectAllNotFailingPeers(int howMany, Set exclude, Set matches, boolean onlyNotFailing, int mask) { private void selectAllNotFailingPeers(int howMany, Set exclude, Set matches, boolean onlyNotFailing, int mask) {
if (matches.size() < howMany) { if (matches.size() < howMany) {
int orig = matches.size(); int orig = matches.size();
......
...@@ -42,10 +42,15 @@ class ExploratoryPeerSelector extends TunnelPeerSelector { ...@@ -42,10 +42,15 @@ class ExploratoryPeerSelector extends TunnelPeerSelector {
// exclude.addAll(fac.getFloodfillPeers()); // exclude.addAll(fac.getFloodfillPeers());
HashSet matches = new HashSet(length); HashSet matches = new HashSet(length);
boolean exploreHighCap = shouldPickHighCap(ctx); boolean exploreHighCap = shouldPickHighCap(ctx);
//
// We don't honor IP Restriction here, to be fixed
//
if (exploreHighCap) if (exploreHighCap)
ctx.profileOrganizer().selectHighCapacityPeers(length, exclude, matches); ctx.profileOrganizer().selectHighCapacityPeers(length, exclude, matches);
else else if (ctx.commSystem().haveOutboundCapacity())
ctx.profileOrganizer().selectNotFailingPeers(length, exclude, matches, false); ctx.profileOrganizer().selectNotFailingPeers(length, exclude, matches, false);
else // use only connected peers so we don't make more connections
ctx.profileOrganizer().selectActiveNotFailingPeers(length, exclude, matches);
if (l.shouldLog(Log.DEBUG)) if (l.shouldLog(Log.DEBUG))
l.debug("profileOrganizer.selectNotFailing(" + length + ") found " + matches); l.debug("profileOrganizer.selectNotFailing(" + length + ") found " + matches);
......
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