fix: compilation issue when `libp2p_expensive_metrics` is enabled. (#1014)

This commit is contained in:
diegomrsantos 2024-01-29 11:31:11 +01:00 committed by GitHub
parent 9468bb6b4d
commit d46bcdb6ac
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 6 deletions

View File

@ -426,6 +426,11 @@ method rpcHandler*(g: GossipSub,
await rateLimit(g, peer, Opt.none(RPCMsg), msgSize)
return
when defined(libp2p_expensive_metrics):
for m in rpcMsg.messages:
for t in m.topicIDs:
libp2p_pubsub_received_messages.inc(labelValues = [$peer.peerId, t])
trace "decoded msg from peer", peer, msg = rpcMsg.shortLog
await rateLimit(g, peer, Opt.some(rpcMsg), msgSize)

View File

@ -138,12 +138,6 @@ proc handle*(p: PubSubPeer, conn: Connection) {.async.} =
conn, peer = p, closed = conn.closed,
data = data.shortLog
when defined(libp2p_expensive_metrics):
for m in rmsg.messages:
for t in m.topicIDs:
# metrics
libp2p_pubsub_received_messages.inc(labelValues = [$p.peerId, t])
await p.handler(p, data)
data = newSeq[byte]() # Release memory
except PeerRateLimitError as exc: