@@ -265,32 +265,31 @@ proc addCapped*[T](stat: var T, diff, cap: T) =
265
265
proc rewardDelivered * (
266
266
g: GossipSub ,
267
267
peer: PubSubPeer ,
268
- topics: openArray [ string ] ,
268
+ topic: string ,
269
269
first: bool ,
270
270
delay = ZeroDuration ,
271
271
) =
272
- for tt in topics:
273
- let t = tt
274
- if t notin g.topics:
275
- continue
272
+ let t = topic
273
+ if t notin g.topics:
274
+ return
276
275
277
- let tt = t
276
+ let topic = t
278
277
279
- let topicParams = g.topicParams.mgetOrPut (t, TopicParams .init ())
280
- # if in mesh add more delivery score
278
+ let topicParams = g.topicParams.mgetOrPut (t, TopicParams .init ())
279
+ # if in mesh add more delivery score
281
280
282
- if delay > topicParams.meshMessageDeliveriesWindow:
283
- # Too old
284
- continue
281
+ if delay > topicParams.meshMessageDeliveriesWindow:
282
+ # Too old
283
+ continue
284
+
285
+ g.withPeerStats (peer.peerId) do (stats: var PeerStats ):
286
+ stats.topicInfos.withValue (topic, tstats):
287
+ if first:
288
+ tstats[].firstMessageDeliveries.addCapped (
289
+ 1 , topicParams.firstMessageDeliveriesCap)
285
290
286
- g.withPeerStats (peer.peerId) do (stats: var PeerStats ):
287
- stats.topicInfos.withValue (tt, tstats):
288
- if first:
289
- tstats[].firstMessageDeliveries.addCapped (
290
- 1 , topicParams.firstMessageDeliveriesCap)
291
-
292
- if tstats[].inMesh:
293
- tstats[].meshMessageDeliveries.addCapped (
294
- 1 , topicParams.meshMessageDeliveriesCap)
295
- do : # make sure we don't lose this information
296
- stats.topicInfos[tt] = TopicInfo (meshMessageDeliveries: 1 )
291
+ if tstats[].inMesh:
292
+ tstats[].meshMessageDeliveries.addCapped (
293
+ 1 , topicParams.meshMessageDeliveriesCap)
294
+ do : # make sure we don't lose this information
295
+ stats.topicInfos[topic] = TopicInfo (meshMessageDeliveries: 1 )
0 commit comments