@@ -220,8 +220,6 @@ method unsubscribePeer*(g: GossipSub, peer: PeerId) =
220
220
for topic, info in stats[].topicInfos.mpairs:
221
221
info.firstMessageDeliveries = 0
222
222
223
- pubSubPeer.stopSendNonPriorityTask ()
224
-
225
223
procCall FloodSub (g).unsubscribePeer (peer)
226
224
227
225
proc handleSubscribe * (g: GossipSub ,
@@ -281,40 +279,31 @@ proc handleControl(g: GossipSub, peer: PubSubPeer, control: ControlMessage) =
281
279
respControl.prune.add (g.handleGraft (peer, control.graft))
282
280
let messages = g.handleIWant (peer, control.iwant)
283
281
284
- let
285
- isPruneNotEmpty = respControl.prune.len > 0
286
- isIWantNotEmpty = respControl.iwant.len > 0
287
-
288
- if isPruneNotEmpty or isIWantNotEmpty:
289
-
290
- if isIWantNotEmpty:
291
- libp2p_pubsub_broadcast_iwant.inc (respControl.iwant.len.int64 )
292
-
293
- if isPruneNotEmpty:
294
- for prune in respControl.prune:
295
- if g.knownTopics.contains (prune.topicId):
296
- libp2p_pubsub_broadcast_prune.inc (labelValues = [prune.topicId])
297
- else :
298
- libp2p_pubsub_broadcast_prune.inc (labelValues = [" generic" ])
299
-
300
- trace " sending control message" , msg = shortLog (respControl), peer
301
- g.send (
302
- peer,
303
- RPCMsg (control: some (respControl)), isHighPriority = true )
282
+ if
283
+ respControl.prune.len > 0 or
284
+ respControl.iwant.len > 0 or
285
+ messages.len > 0 :
286
+ # iwant and prunes from here, also messages
304
287
305
- if messages.len > 0 :
306
288
for smsg in messages:
307
289
for topic in smsg.topicIds:
308
290
if g.knownTopics.contains (topic):
309
291
libp2p_pubsub_broadcast_messages.inc (labelValues = [topic])
310
292
else :
311
293
libp2p_pubsub_broadcast_messages.inc (labelValues = [" generic" ])
312
294
313
- # iwant replies have lower priority
314
- trace " sending iwant reply messages" , peer
295
+ libp2p_pubsub_broadcast_iwant.inc (respControl.iwant.len.int64 )
296
+
297
+ for prune in respControl.prune:
298
+ if g.knownTopics.contains (prune.topicId):
299
+ libp2p_pubsub_broadcast_prune.inc (labelValues = [prune.topicId])
300
+ else :
301
+ libp2p_pubsub_broadcast_prune.inc (labelValues = [" generic" ])
302
+
303
+ trace " sending control message" , msg = shortLog (respControl), peer
315
304
g.send (
316
305
peer,
317
- RPCMsg (messages: messages ), isHighPriority = false )
306
+ RPCMsg (control: some (respControl ), messages: messages) )
318
307
319
308
proc validateAndRelay (g: GossipSub ,
320
309
msg: Message ,
@@ -367,7 +356,7 @@ proc validateAndRelay(g: GossipSub,
367
356
if msg.data.len > msgId.len * 10 :
368
357
g.broadcast (toSendPeers, RPCMsg (control: some (ControlMessage (
369
358
idontwant: @ [ControlIWant (messageIds: @ [msgId])]
370
- ))), isHighPriority = true )
359
+ ))))
371
360
372
361
for peer in toSendPeers:
373
362
for heDontWant in peer.heDontWants:
@@ -381,7 +370,7 @@ proc validateAndRelay(g: GossipSub,
381
370
382
371
# In theory, if topics are the same in all messages, we could batch - we'd
383
372
# also have to be careful to only include validated messages
384
- g.broadcast (toSendPeers, RPCMsg (messages: @ [msg]), isHighPriority = false )
373
+ g.broadcast (toSendPeers, RPCMsg (messages: @ [msg]))
385
374
trace " forwarded message to peers" , peers = toSendPeers.len, msgId, peer
386
375
for topic in msg.topicIds:
387
376
if topic notin g.topics: continue
@@ -452,7 +441,7 @@ method rpcHandler*(g: GossipSub,
452
441
peer.recvObservers (rpcMsg)
453
442
454
443
if rpcMsg.ping.len in 1 ..< 64 and peer.pingBudget > 0 :
455
- g.send (peer, RPCMsg (pong: rpcMsg.ping), isHighPriority = true )
444
+ g.send (peer, RPCMsg (pong: rpcMsg.ping))
456
445
peer.pingBudget.dec
457
446
for i in 0 ..< min (g.topicsHigh, rpcMsg.subscriptions.len):
458
447
template sub : untyped = rpcMsg.subscriptions[i]
@@ -562,7 +551,7 @@ method onTopicSubscription*(g: GossipSub, topic: string, subscribed: bool) =
562
551
topicID: topic,
563
552
peers: g.peerExchangeList (topic),
564
553
backoff: g.parameters.unsubscribeBackoff.seconds.uint64 )])))
565
- g.broadcast (mpeers, msg, isHighPriority = true )
554
+ g.broadcast (mpeers, msg)
566
555
567
556
for peer in mpeers:
568
557
g.pruned (peer, topic, backoff = some (g.parameters.unsubscribeBackoff))
@@ -666,7 +655,7 @@ method publish*(g: GossipSub,
666
655
667
656
g.mcache.put (msgId, msg)
668
657
669
- g.broadcast (peers, RPCMsg (messages: @ [msg]), isHighPriority = true )
658
+ g.broadcast (peers, RPCMsg (messages: @ [msg]))
670
659
671
660
if g.knownTopics.contains (topic):
672
661
libp2p_pubsub_messages_published.inc (peers.len.int64 , labelValues = [topic])
0 commit comments