* TunnelPeerSelector: Avoid a peer for 20s after a reject or timeout
This commit is contained in:
@ -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 {
|
|||||||
// 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);
|
||||||
|
Reference in New Issue
Block a user