wait for non-priority msg first before checking the priority queue

This commit is contained in:
Diego 2024-02-09 14:42:06 +01:00
parent a1f3940c06
commit 20a8e57262
No known key found for this signature in database
GPG Key ID: C9DAC9BF68D1F806
1 changed files with 2 additions and 2 deletions

View File

@ -372,11 +372,11 @@ proc clearSendPriorityQueue(p: PubSubPeer) =
proc sendNonPriorityTask(p: PubSubPeer) {.async.} =
while true:
# we send non-priority messages only if there are no pending priority messages
let msg = await p.rpcmessagequeue.nonPriorityQueue.popFirst()
while p.rpcmessagequeue.sendPriorityQueue.len > 0:
await p.rpcmessagequeue.sendPriorityQueue[0]
p.clearSendPriorityQueue()
# we send non-priority messages only if there are no pending priority messages
let msg = await p.rpcmessagequeue.nonPriorityQueue.popFirst()
when defined(libp2p_expensive_metrics):
libp2p_gossipsub_non_priority_queue_size.dec(labelValues = [$p.peerId])
await p.sendMsg(msg)