mirror of
https://github.com/vacp2p/nim-libp2p.git
synced 2026-01-10 12:58:05 -05:00
Compare commits
2 Commits
async-fix
...
idontwant-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2979fcba0e | ||
|
|
c98f3eefa0 |
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user