@@ -50,7 +50,7 @@ func (h Handler[T]) AppRequest(_ context.Context, _ ids.NodeID, _ time.Time, req
5050 return nil , p2p .ErrUnexpected
5151 }
5252
53- var hits , total uint64
53+ var hits , total float64
5454
5555 responseSize := 0
5656 gossipBytes := make ([][]byte , 0 )
@@ -81,7 +81,7 @@ func (h Handler[T]) AppRequest(_ context.Context, _ ids.NodeID, _ time.Time, req
8181 return nil , p2p .ErrUnexpected
8282 }
8383
84- hitsPercentage , ok := computeBloomFilterHitPercentage (hits , total , h . log )
84+ hitsPercentage , ok := computeBloomFilterHitPercentage (hits , total )
8585 if ok {
8686 h .metrics .bloomFilterHitRate .Observe (float64 (hitsPercentage ))
8787 }
@@ -134,20 +134,9 @@ func (h Handler[_]) AppGossip(_ context.Context, nodeID ids.NodeID, gossipBytes
134134 }
135135}
136136
137- func computeBloomFilterHitPercentage (hits uint64 , total uint64 , log logging. Logger ) (uint64 , bool ) {
137+ func computeBloomFilterHitPercentage (hits float64 , total float64 ) (uint64 , bool ) {
138138 if total == 0 {
139139 return 0 , false
140140 }
141-
142- if hits > total {
143- log .Warn ("hits bigger than total, probably an overflow during iteration, aborting hit ratio calculation" ,
144- zap .Uint64 ("hits" , hits ),
145- zap .Uint64 ("total" , total ),
146- )
147- return 0 , false
148- }
149-
150- ratio := float64 (hits ) / float64 (total )
151-
152- return uint64 (float64 (100 ) * ratio ), true
141+ return uint64 ((hits * 100 ) / total ), true
153142}
0 commit comments