Skip to content

Commit d46bcdb

Browse files
fix: compilation issue when libp2p_expensive_metrics is enabled. (#1014)
1 parent 9468bb6 commit d46bcdb

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

libp2p/protocols/pubsub/gossipsub.nim

+5
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,11 @@ method rpcHandler*(g: GossipSub,
426426
await rateLimit(g, peer, Opt.none(RPCMsg), msgSize)
427427
return
428428

429+
when defined(libp2p_expensive_metrics):
430+
for m in rpcMsg.messages:
431+
for t in m.topicIDs:
432+
libp2p_pubsub_received_messages.inc(labelValues = [$peer.peerId, t])
433+
429434
trace "decoded msg from peer", peer, msg = rpcMsg.shortLog
430435
await rateLimit(g, peer, Opt.some(rpcMsg), msgSize)
431436

libp2p/protocols/pubsub/pubsubpeer.nim

-6
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,6 @@ proc handle*(p: PubSubPeer, conn: Connection) {.async.} =
138138
conn, peer = p, closed = conn.closed,
139139
data = data.shortLog
140140

141-
when defined(libp2p_expensive_metrics):
142-
for m in rmsg.messages:
143-
for t in m.topicIDs:
144-
# metrics
145-
libp2p_pubsub_received_messages.inc(labelValues = [$p.peerId, t])
146-
147141
await p.handler(p, data)
148142
data = newSeq[byte]() # Release memory
149143
except PeerRateLimitError as exc:

0 commit comments

Comments
 (0)