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

Skip to content
Snippets Groups Projects
Unverified Commit 513a33ab authored by zzz's avatar zzz
Browse files

Profiles: Capacity calculator minor cleanup

parent b3138173
No related branches found
No related tags found
No related merge requests found
...@@ -35,12 +35,13 @@ class CapacityCalculator { ...@@ -35,12 +35,13 @@ class CapacityCalculator {
public static double calc(PeerProfile profile) { public static double calc(PeerProfile profile) {
double capacity; double capacity;
TunnelHistory history = profile.getTunnelHistory();
if (tooOld(profile)) { if (tooOld(profile)) {
capacity = 1; capacity = 1;
} else { } else {
RateStat acceptStat = profile.getTunnelCreateResponseTime(); RateStat acceptStat = profile.getTunnelCreateResponseTime();
RateStat rejectStat = profile.getTunnelHistory().getRejectionRate(); RateStat rejectStat = history.getRejectionRate();
RateStat failedStat = profile.getTunnelHistory().getFailedRate(); RateStat failedStat = history.getFailedRate();
double capacity10m = estimateCapacity(acceptStat, rejectStat, failedStat, 10*60*1000); double capacity10m = estimateCapacity(acceptStat, rejectStat, failedStat, 10*60*1000);
// if we actively know they're bad, who cares if they used to be good? // if we actively know they're bad, who cares if they used to be good?
...@@ -62,9 +63,9 @@ class CapacityCalculator { ...@@ -62,9 +63,9 @@ class CapacityCalculator {
// incremented the rejection counter, since they were only temporary) // incremented the rejection counter, since they were only temporary)
RouterContext context = profile.getContext(); RouterContext context = profile.getContext();
long now = context.clock().now(); long now = context.clock().now();
if (profile.getTunnelHistory().getLastRejectedTransient() > now - 5*60*1000) if (history.getLastRejectedTransient() > now - 5*60*1000)
capacity = 1; capacity = 1;
else if (profile.getTunnelHistory().getLastRejectedProbabalistic() > now - 5*60*1000) else if (history.getLastRejectedProbabalistic() > now - 5*60*1000)
capacity -= context.random().nextInt(5); capacity -= context.random().nextInt(5);
// boost new profiles // boost new profiles
......
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