put verified sources in the responder cache as well

This commit is contained in:
Zlatin Balevsky
2020-09-23 11:30:20 +01:00
parent 0ebe00b526
commit c73a821c67
3 changed files with 7 additions and 1 deletions

View File

@ -313,6 +313,7 @@ public class Core {
log.info("initializing responder cache")
ResponderCache responderCache = new ResponderCache(props.responderCacheSize)
eventBus.register(UIResultBatchEvent.class, responderCache)
eventBus.register(SourceVerifiedEvent.class, responderCache)
log.info("initializing connection manager")

View File

@ -56,7 +56,7 @@ class UltrapeerConnectionManager extends ConnectionManager {
peerConnections.values().each {
// 1. do not send query back to originator
// 2. if firstHop forward to everyone
// 3. otherwise to everyone who has recently responded to us + randomized sqrt of neighbors
// 3. otherwise to everyone who has recently responded/transferred to us + randomized sqrt of neighbors
if (e.getReceivedOn() != it.getEndpoint().getDestination() &&
(e.firstHop ||
responderCache.hasResponded(it.endpoint.destination) ||

View File

@ -1,5 +1,6 @@
package com.muwire.core.search
import com.muwire.core.download.SourceVerifiedEvent
import com.muwire.core.util.FixedSizeFIFOSet
import net.i2p.data.Destination
@ -19,6 +20,10 @@ class ResponderCache {
cache.add(e.results[0].sender.destination)
}
synchronized void onSourceVerifiedEvent(SourceVerifiedEvent e) {
cache.add(e.source)
}
synchronized boolean hasResponded(Destination d) {
cache.contains(d)
}