Skip to content

Commit

Permalink
rename ttl property
Browse files Browse the repository at this point in the history
  • Loading branch information
diegomrsantos committed Feb 1, 2024
1 parent dcd6014 commit ed4cd60
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions libp2p/protocols/pubsub/pubsubpeer.nim
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ type

Ttlmessage* = object
msg*: seq[byte]
ttl*: Moment
timestamp*: Moment

RpcMessageQueue* = ref object
sendPriorityQueue: Deque[Future[void]]
Expand Down Expand Up @@ -298,7 +298,7 @@ proc sendEncoded*(p: PubSubPeer, msg: seq[byte], isHighPriority: bool = false) {
when defined(libp2p_expensive_metrics):
libp2p_gossipsub_priority_queue_size.inc(labelValues = [$p.peerId])
else:
await p.rpcmessagequeue.nonPriorityQueue.addLast(Ttlmessage(msg: msg, ttl: Moment.now()))
await p.rpcmessagequeue.nonPriorityQueue.addLast(Ttlmessage(msg: msg, timestamp: Moment.now()))
when defined(libp2p_expensive_metrics):
libp2p_gossipsub_non_priority_queue_size.inc(labelValues = [$p.peerId])
trace "message queued", p, msg = shortLog(msg)
Expand Down Expand Up @@ -385,7 +385,7 @@ proc sendNonPriorityTask(p: PubSubPeer) {.async.} =
let ttlMsg = await p.rpcmessagequeue.nonPriorityQueue.popFirst()
when defined(libp2p_expensive_metrics):
libp2p_gossipsub_non_priority_queue_size.dec(labelValues = [$p.peerId])
if Moment.now() - ttlMsg.ttl >= p.rpcmessagequeue.maxDurationInNonPriorityQueue:
if Moment.now() - ttlMsg.timestamp >= p.rpcmessagequeue.maxDurationInNonPriorityQueue:
when defined(libp2p_expensive_metrics):
libp2p_gossipsub_non_priority_msgs_dropped.inc(labelValues = [$p.peerId])
continue
Expand Down

0 comments on commit ed4cd60

Please sign in to comment.