mirror of https://github.com/zlatinb/muwire
start with optimistic profile if received from hostcache or a new successful connection has been made
parent
768673e979
commit
38bf4f2ea2
|
@ -42,9 +42,10 @@ class H2HostCache extends HostCache {
|
||||||
protected synchronized void hostDiscovered(Destination d, boolean fromHostcache) {
|
protected synchronized void hostDiscovered(Destination d, boolean fromHostcache) {
|
||||||
// overwrite MC with optimistic values
|
// overwrite MC with optimistic values
|
||||||
if (fromHostcache) {
|
if (fromHostcache) {
|
||||||
sql.execute("delete from HOST_ATTEMPTS where DESTINATION='${d.toBase64()}';")
|
sql.execute("delete from HOST_ATTEMPTS where DESTINATION=${d.toBase64()}")
|
||||||
profiles.put(d, new HostMCProfile())
|
profiles.put(d, new HostMCProfile())
|
||||||
} else if (uniqueHosts.add(d)) {
|
}
|
||||||
|
if (uniqueHosts.add(d)) {
|
||||||
allHosts.add(d)
|
allHosts.add(d)
|
||||||
profiles.put(d, new HostMCProfile())
|
profiles.put(d, new HostMCProfile())
|
||||||
}
|
}
|
||||||
|
@ -55,6 +56,11 @@ class H2HostCache extends HostCache {
|
||||||
|
|
||||||
log.fine("onConnection ${d.toBase32()} status $status")
|
log.fine("onConnection ${d.toBase32()} status $status")
|
||||||
|
|
||||||
|
if (status == ConnectionAttemptStatus.SUCCESSFUL && uniqueHosts.add(d)) {
|
||||||
|
allHosts.add(d)
|
||||||
|
profiles.put(d, new HostMCProfile())
|
||||||
|
}
|
||||||
|
|
||||||
// record into db
|
// record into db
|
||||||
def timestamp = new Date(System.currentTimeMillis())
|
def timestamp = new Date(System.currentTimeMillis())
|
||||||
timestamp = SDF.format(timestamp)
|
timestamp = SDF.format(timestamp)
|
||||||
|
|
Loading…
Reference in New Issue