From 2bfcbbf1c5b8f7ed16865fb0bb6c0e46240deccf Mon Sep 17 00:00:00 2001 From: Zlatin Balevsky Date: Sun, 10 Oct 2021 08:11:55 +0100 Subject: [PATCH] mark local queries and make sure they get broadcast --- .../muwire/core/connection/UltrapeerConnectionManager.groovy | 4 ++-- core/src/main/groovy/com/muwire/core/search/QueryEvent.groovy | 2 +- .../main/groovy/com/muwire/core/update/UpdateClient.groovy | 2 +- .../controllers/com/muwire/gui/MainFrameController.groovy | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/core/src/main/groovy/com/muwire/core/connection/UltrapeerConnectionManager.groovy b/core/src/main/groovy/com/muwire/core/connection/UltrapeerConnectionManager.groovy index 9e2b62a8..c43e2a77 100644 --- a/core/src/main/groovy/com/muwire/core/connection/UltrapeerConnectionManager.groovy +++ b/core/src/main/groovy/com/muwire/core/connection/UltrapeerConnectionManager.groovy @@ -46,7 +46,7 @@ class UltrapeerConnectionManager extends ConnectionManager { void onQueryEvent(QueryEvent e) { forwardQueryToLeafs(e) - if (!e.firstHop) + if (!e.firstHop && !e.local) return if (e.replyTo != me.destination && e.receivedOn != me.destination && !leafConnections.containsKey(e.receivedOn)) @@ -60,7 +60,7 @@ class UltrapeerConnectionManager extends ConnectionManager { // 2. if firstHop forward to everyone // 3. otherwise to everyone who has recently responded/transferred to us + randomized sqrt of neighbors if (e.getReceivedOn() != it.getEndpoint().getDestination() && - (e.firstHop || + (e.firstHop || e.local || responderCache.hasResponded(it.endpoint.destination) || random.nextInt(connCount) < treshold)) it.sendQuery(e) diff --git a/core/src/main/groovy/com/muwire/core/search/QueryEvent.groovy b/core/src/main/groovy/com/muwire/core/search/QueryEvent.groovy index 0187b77f..5321fa75 100644 --- a/core/src/main/groovy/com/muwire/core/search/QueryEvent.groovy +++ b/core/src/main/groovy/com/muwire/core/search/QueryEvent.groovy @@ -8,7 +8,7 @@ import net.i2p.data.Destination class QueryEvent extends Event { SearchEvent searchEvent - boolean firstHop + boolean firstHop, local Destination replyTo Persona originator Destination receivedOn diff --git a/core/src/main/groovy/com/muwire/core/update/UpdateClient.groovy b/core/src/main/groovy/com/muwire/core/update/UpdateClient.groovy index 9aba0604..21c398ee 100644 --- a/core/src/main/groovy/com/muwire/core/update/UpdateClient.groovy +++ b/core/src/main/groovy/com/muwire/core/update/UpdateClient.groovy @@ -184,7 +184,7 @@ class UpdateClient { long timestamp = System.currentTimeMillis() byte [] sig2 = DataUtil.signUUID(uuid, timestamp, spk) def searchEvent = new SearchEvent(searchHash : updateInfoHash.getRoot(), uuid : uuid, oobInfohash : true, persona : me) - def queryEvent = new QueryEvent(searchEvent : searchEvent, firstHop : true, replyTo : me.destination, + def queryEvent = new QueryEvent(searchEvent : searchEvent, firstHop : true, local: true, replyTo : me.destination, receivedOn : me.destination, originator : me, sig : sig.data, queryTime : timestamp, sig2 : sig2) eventBus.publish(queryEvent) } diff --git a/gui/griffon-app/controllers/com/muwire/gui/MainFrameController.groovy b/gui/griffon-app/controllers/com/muwire/gui/MainFrameController.groovy index 79a9dabd..f6fcc51e 100644 --- a/gui/griffon-app/controllers/com/muwire/gui/MainFrameController.groovy +++ b/gui/griffon-app/controllers/com/muwire/gui/MainFrameController.groovy @@ -146,7 +146,7 @@ class MainFrameController { Signature sig = DSAEngine.getInstance().sign(payload, core.spk) long timestamp = System.currentTimeMillis() - core.eventBus.publish(new QueryEvent(searchEvent : searchEvent, firstHop : firstHop, + core.eventBus.publish(new QueryEvent(searchEvent : searchEvent, firstHop : firstHop, local: true, replyTo: core.me.destination, receivedOn: core.me.destination, originator : core.me, sig : sig.data, queryTime : timestamp, sig2 : DataUtil.signUUID(uuid, timestamp, core.spk))) @@ -171,7 +171,7 @@ class MainFrameController { def searchEvent = new SearchEvent(searchHash : Base64.decode(infoHash), uuid:uuid, oobInfohash: true, persona : core.me) - core.eventBus.publish(new QueryEvent(searchEvent : searchEvent, firstHop : true, + core.eventBus.publish(new QueryEvent(searchEvent : searchEvent, firstHop : true, local: true, replyTo: core.me.destination, receivedOn: core.me.destination, originator : core.me, sig : sig.data, queryTime : timestamp, sig2 : sig2)) }