* ProfileOrganizer: Add profileOrganizer.sameCountryBonus config

This commit is contained in:
zzz
2012-02-04 14:46:24 +00:00
parent 4bd869f5fa
commit d93805eb96
4 changed files with 32 additions and 4 deletions

View File

@@ -18,7 +18,7 @@ public class RouterVersion {
/** deprecated */
public final static String ID = "Monotone";
public final static String VERSION = CoreVersion.VERSION;
public final static long BUILD = 10;
public final static long BUILD = 11;
/** for example "-test" */
public final static String EXTRA = "";

View File

@@ -10,6 +10,8 @@ import net.i2p.stat.RateStat;
class CapacityCalculator {
private static final I2PAppContext _context = I2PAppContext.getGlobalContext();
public static final String PROP_COUNTRY_BONUS = "profileOrganizer.sameCountryBonus";
/** used to adjust each period so that we keep trying to expand the peer's capacity */
static final long GROWTH_FACTOR = 5;
@@ -65,8 +67,16 @@ class CapacityCalculator {
if (profile.isEstablished())
capacity += BONUS_ESTABLISHED;
// boost same country
if (profile.isSameCountry())
capacity += BONUS_SAME_COUNTRY;
if (profile.isSameCountry()) {
double bonus = BONUS_SAME_COUNTRY;
String b = _context.getProperty(PROP_COUNTRY_BONUS);
if (b != null) {
try {
bonus = Double.parseDouble(b);
} catch (NumberFormatException nfe) {}
}
capacity += bonus;
}
// penalize unreachable peers
if (profile.wasUnreachable())
capacity -= PENALTY_UNREACHABLE;

View File

@@ -134,7 +134,8 @@ public class PeerProfile {
boolean isSameCountry() {
String us = _context.commSystem().getOurCountry();
return us != null &&
_bigCountries.contains(us) &&
(_bigCountries.contains(us) ||
_context.getProperty(CapacityCalculator.PROP_COUNTRY_BONUS) != null) &&
us.equals(_context.commSystem().getCountry(_peer));
}