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

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

* TunnelPeerSelector: Avoid a peer for 20s after a reject or timeout

parent e5c7b79c
No related branches found
No related tags found
No related merge requests found
...@@ -477,6 +477,25 @@ public class ProfileOrganizer { ...@@ -477,6 +477,25 @@ public class ProfileOrganizer {
return l; return l;
} }
/**
* Get the peers that have recently rejected us for bandwidth
* recent == last 20s
*
*/
public List selectPeersRecentlyRejecting() {
synchronized (_reorganizeLock) {
long cutoff = _context.clock().now() - (20*1000);
int count = _notFailingPeers.size();
List l = new ArrayList(count / 128);
for (Iterator iter = _notFailingPeers.values().iterator(); iter.hasNext(); ) {
PeerProfile prof = (PeerProfile) iter.next();
if (prof.getTunnelHistory().getLastRejectedBandwidth() > cutoff)
l.add(prof.getPeer());
}
return l;
}
}
/** /**
* Find the hashes for all peers we are actively profiling * Find the hashes for all peers we are actively profiling
* *
......
...@@ -176,6 +176,7 @@ public abstract class TunnelPeerSelector { ...@@ -176,6 +176,7 @@ public abstract class TunnelPeerSelector {
// Defaults changed to true for inbound only in filterUnreachable below. // Defaults changed to true for inbound only in filterUnreachable below.
Set peers = new HashSet(1); Set peers = new HashSet(1);
peers.addAll(ctx.profileOrganizer().selectPeersRecentlyRejecting());
// if (false && filterUnreachable(ctx, isInbound, isExploratory)) { // if (false && filterUnreachable(ctx, isInbound, isExploratory)) {
if (filterUnreachable(ctx, isInbound, isExploratory)) { if (filterUnreachable(ctx, isInbound, isExploratory)) {
List caps = ctx.peerManager().getPeersByCapability(Router.CAPABILITY_UNREACHABLE); List caps = ctx.peerManager().getPeersByCapability(Router.CAPABILITY_UNREACHABLE);
......
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