Compare commits

...

2 Commits

Author SHA1 Message Date
Gabriel Cruz
2979fcba0e Merge branch 'master' into idontwant-mesh 2025-05-06 17:07:09 -03:00
Richard Ramos
c98f3eefa0 fix: only send IDONT to mesh peers 2025-02-18 16:12:01 -04:00

View File

@@ -423,18 +423,9 @@ proc validateAndRelay(
template topic(): string =
msg.topic
proc addToSendPeers(toSendPeers: var HashSet[PubSubPeer]) =
g.floodsub.withValue(topic, peers):
toSendPeers.incl(peers[])
g.mesh.withValue(topic, peers):
toSendPeers.incl(peers[])
g.subscribedDirectPeers.withValue(topic, peers):
toSendPeers.incl(peers[])
toSendPeers.excl(peer)
if isLargeMessage(msg, msgId):
var peersToSendIDontWant = HashSet[PubSubPeer]()
addToSendPeers(peersToSendIDontWant)
var peersToSendIDontWant = g.mesh.getOrDefault(topic)
peersToSendIDontWant.excl(peer)
g.sendIDontWant(msg, msgId, peersToSendIDontWant)
let validation = await g.validate(msg)
@@ -470,8 +461,15 @@ proc validateAndRelay(
# trigger hooks
peer.validatedObservers(msg, msgId)
# The send list typically matches the idontwant list from above, but
# might differ if validation takes time
proc addToSendPeers(toSendPeers: var HashSet[PubSubPeer]) =
g.floodsub.withValue(topic, peers):
toSendPeers.incl(peers[])
g.mesh.withValue(topic, peers):
toSendPeers.incl(peers[])
g.subscribedDirectPeers.withValue(topic, peers):
toSendPeers.incl(peers[])
toSendPeers.excl(peer)
var toSendPeers = HashSet[PubSubPeer]()
addToSendPeers(toSendPeers)
# Don't send it to peers that sent it during validation
@@ -805,7 +803,7 @@ method publish*(
g.mcache.put(msgId, msg)
if g.parameters.sendIDontWantOnPublish and isLargeMessage(msg, msgId):
g.sendIDontWant(msg, msgId, peers)
g.sendIDontWant(msg, msgId, g.mesh.getOrDefault(topic))
g.broadcast(peers, RPCMsg(messages: @[msg]), isHighPriority = true)