Skip to content

Commit 5bba0f5

Browse files
committed
rename ttl property and message type
1 parent dcd6014 commit 5bba0f5

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

libp2p/protocols/pubsub/pubsubpeer.nim

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,13 @@ type
5656
DropConn* = proc(peer: PubSubPeer) {.gcsafe, raises: [].} # have to pass peer as it's unknown during init
5757
OnEvent* = proc(peer: PubSubPeer, event: PubSubPeerEvent) {.gcsafe, raises: [].}
5858

59-
Ttlmessage* = object
59+
QueuedMessage* = object
6060
msg*: seq[byte]
61-
ttl*: Moment
61+
addedAt*: Moment
6262

6363
RpcMessageQueue* = ref object
6464
sendPriorityQueue: Deque[Future[void]]
65-
nonPriorityQueue: AsyncQueue[Ttlmessage]
65+
nonPriorityQueue: AsyncQueue[QueuedMessage]
6666
sendNonPriorityTask: Future[void]
6767
# The max duration a message to be relayed can wait to be sent before it is dropped. The default is 500ms.
6868
maxDurationInNonPriorityQueue: Duration
@@ -298,7 +298,7 @@ proc sendEncoded*(p: PubSubPeer, msg: seq[byte], isHighPriority: bool = false) {
298298
when defined(libp2p_expensive_metrics):
299299
libp2p_gossipsub_priority_queue_size.inc(labelValues = [$p.peerId])
300300
else:
301-
await p.rpcmessagequeue.nonPriorityQueue.addLast(Ttlmessage(msg: msg, ttl: Moment.now()))
301+
await p.rpcmessagequeue.nonPriorityQueue.addLast(QueuedMessage(msg: msg, addedAt: Moment.now()))
302302
when defined(libp2p_expensive_metrics):
303303
libp2p_gossipsub_non_priority_queue_size.inc(labelValues = [$p.peerId])
304304
trace "message queued", p, msg = shortLog(msg)
@@ -385,7 +385,7 @@ proc sendNonPriorityTask(p: PubSubPeer) {.async.} =
385385
let ttlMsg = await p.rpcmessagequeue.nonPriorityQueue.popFirst()
386386
when defined(libp2p_expensive_metrics):
387387
libp2p_gossipsub_non_priority_queue_size.dec(labelValues = [$p.peerId])
388-
if Moment.now() - ttlMsg.ttl >= p.rpcmessagequeue.maxDurationInNonPriorityQueue:
388+
if Moment.now() - ttlMsg.addedAt >= p.rpcmessagequeue.maxDurationInNonPriorityQueue:
389389
when defined(libp2p_expensive_metrics):
390390
libp2p_gossipsub_non_priority_msgs_dropped.inc(labelValues = [$p.peerId])
391391
continue
@@ -410,7 +410,7 @@ proc stopSendNonPriorityTask*(p: PubSubPeer) =
410410
proc new(T: typedesc[RpcMessageQueue], maxDurationInNonPriorityQueue = 1.seconds): T =
411411
return T(
412412
sendPriorityQueue: initDeque[Future[void]](),
413-
nonPriorityQueue: newAsyncQueue[Ttlmessage](),
413+
nonPriorityQueue: newAsyncQueue[QueuedMessage](),
414414
maxDurationInNonPriorityQueue: maxDurationInNonPriorityQueue,
415415
)
416416

0 commit comments

Comments
 (0)