diff --git a/core/src/main/groovy/com/muwire/core/hostcache/H2HostCache.groovy b/core/src/main/groovy/com/muwire/core/hostcache/H2HostCache.groovy index a86d461b..06345e65 100644 --- a/core/src/main/groovy/com/muwire/core/hostcache/H2HostCache.groovy +++ b/core/src/main/groovy/com/muwire/core/hostcache/H2HostCache.groovy @@ -177,7 +177,7 @@ class H2HostCache extends HostCache { "'${String.format(Locale.US, "%.6f",ffd)}'" + ")") def newProfile = sql.firstRow("select * from HOST_PROFILES where DESTINATION=${d.toBase64()}") - profiles.put(d, new HostMCProfile(newProfile)) + profiles.put(d, new HostMCProfile(newProfile, status)) log.fine("profile updated ${d.toBase32()} ${profiles.get(d)}") sql.execute("delete from HOST_ATTEMPTS where DESTINATION=${d.toBase64()} and TSTAMP not in "+ @@ -313,7 +313,7 @@ class H2HostCache extends HostCache { def fromDB = sql.firstRow("select * from HOST_PROFILES where DESTINATION=${dest.toBase64()}") def profile = new HostMCProfile() if (fromDB != null) - profile = new HostMCProfile(fromDB) + profile = new HostMCProfile(fromDB, ConnectionAttemptStatus.SUCCESSFUL) profiles.put(dest, profile) allHosts.add(dest) log.fine("Loaded profile for ${dest.toBase32()} $profile") diff --git a/core/src/main/groovy/com/muwire/core/hostcache/HostMCProfile.groovy b/core/src/main/groovy/com/muwire/core/hostcache/HostMCProfile.groovy index fa968cf5..9deefa2c 100644 --- a/core/src/main/groovy/com/muwire/core/hostcache/HostMCProfile.groovy +++ b/core/src/main/groovy/com/muwire/core/hostcache/HostMCProfile.groovy @@ -35,7 +35,7 @@ class HostMCProfile { private final String toString // start with S - ConnectionAttemptStatus state = ConnectionAttemptStatus.SUCCESSFUL + ConnectionAttemptStatus state boolean hasHistory boolean successfulAttempt @@ -45,6 +45,7 @@ class HostMCProfile { */ HostMCProfile() { this.hasHistory = false + this.state = ConnectionAttemptStatus.SUCCESSFUL S = new Probability[3] R = new Probability[3] F = new Probability[3] @@ -84,7 +85,8 @@ class HostMCProfile { /** * historical predictor loaded from database */ - HostMCProfile(def fromDB) { + HostMCProfile(def fromDB, ConnectionAttemptStatus currentStatus) { + state = currentStatus hasHistory = true S = new Probability[3]