diff --git a/router/java/src/net/i2p/router/peermanager/CapacityCalculator.java b/router/java/src/net/i2p/router/peermanager/CapacityCalculator.java index 326b709d2e635fc5b8c6bcb5d1d4b705b218e80a..6a2f6223c9ce440a9e23b7c325c2d2d3f2b4f1ba 100644 --- a/router/java/src/net/i2p/router/peermanager/CapacityCalculator.java +++ b/router/java/src/net/i2p/router/peermanager/CapacityCalculator.java @@ -35,12 +35,13 @@ class CapacityCalculator { public static double calc(PeerProfile profile) { double capacity; + TunnelHistory history = profile.getTunnelHistory(); if (tooOld(profile)) { capacity = 1; } else { RateStat acceptStat = profile.getTunnelCreateResponseTime(); - RateStat rejectStat = profile.getTunnelHistory().getRejectionRate(); - RateStat failedStat = profile.getTunnelHistory().getFailedRate(); + RateStat rejectStat = history.getRejectionRate(); + RateStat failedStat = history.getFailedRate(); double capacity10m = estimateCapacity(acceptStat, rejectStat, failedStat, 10*60*1000); // if we actively know they're bad, who cares if they used to be good? @@ -62,9 +63,9 @@ class CapacityCalculator { // incremented the rejection counter, since they were only temporary) RouterContext context = profile.getContext(); long now = context.clock().now(); - if (profile.getTunnelHistory().getLastRejectedTransient() > now - 5*60*1000) + if (history.getLastRejectedTransient() > now - 5*60*1000) capacity = 1; - else if (profile.getTunnelHistory().getLastRejectedProbabalistic() > now - 5*60*1000) + else if (history.getLastRejectedProbabalistic() > now - 5*60*1000) capacity -= context.random().nextInt(5); // boost new profiles