mirror of https://github.com/zlatinb/muwire
prevent duplicate updates and zero timestamps
parent
5cd1ca88c1
commit
011a4d5766
|
@ -11,7 +11,8 @@ class RemoteTrustList {
|
||||||
|
|
||||||
private final Persona persona
|
private final Persona persona
|
||||||
private final Set<Persona> good, bad
|
private final Set<Persona> good, bad
|
||||||
long timestamp
|
volatile long timestamp
|
||||||
|
volatile boolean forceUpdate
|
||||||
Status status = Status.NEW
|
Status status = Status.NEW
|
||||||
|
|
||||||
RemoteTrustList(Persona persona) {
|
RemoteTrustList(Persona persona) {
|
||||||
|
|
|
@ -53,7 +53,7 @@ class TrustSubscriber {
|
||||||
remoteTrustLists.remove(e.persona.destination)
|
remoteTrustLists.remove(e.persona.destination)
|
||||||
} else {
|
} else {
|
||||||
RemoteTrustList trustList = remoteTrustLists.putIfAbsent(e.persona.destination, new RemoteTrustList(e.persona))
|
RemoteTrustList trustList = remoteTrustLists.putIfAbsent(e.persona.destination, new RemoteTrustList(e.persona))
|
||||||
trustList?.timestamp = 0
|
trustList?.forceUpdate = true
|
||||||
synchronized(waitLock) {
|
synchronized(waitLock) {
|
||||||
waitLock.notify()
|
waitLock.notify()
|
||||||
}
|
}
|
||||||
|
@ -68,8 +68,12 @@ class TrustSubscriber {
|
||||||
}
|
}
|
||||||
final long now = System.currentTimeMillis()
|
final long now = System.currentTimeMillis()
|
||||||
remoteTrustLists.values().each { trustList ->
|
remoteTrustLists.values().each { trustList ->
|
||||||
if (now - trustList.timestamp < settings.trustListInterval * 60 * 60 * 1000)
|
if (trustList.status == RemoteTrustList.Status.UPDATING)
|
||||||
return
|
return
|
||||||
|
if (!trustList.forceUpdate &&
|
||||||
|
now - trustList.timestamp < settings.trustListInterval * 60 * 60 * 1000)
|
||||||
|
return
|
||||||
|
trustList.forceUpdate = false
|
||||||
updateThreads.submit(new UpdateJob(trustList))
|
updateThreads.submit(new UpdateJob(trustList))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue