@@ -311,11 +311,14 @@ impl PeerScore {
311311 if topic_stats. mesh_message_deliveries_active
312312 && topic_stats. mesh_message_deliveries
313313 < topic_params. mesh_message_deliveries_threshold
314+ && topic_params. mesh_message_deliveries_weight != 0.0
314315 {
315316 let deficit = topic_params. mesh_message_deliveries_threshold
316317 - topic_stats. mesh_message_deliveries ;
317318 let p3 = deficit * deficit;
318- topic_score += p3 * topic_params. mesh_message_deliveries_weight ;
319+ let penalty = p3 * topic_params. mesh_message_deliveries_weight ;
320+
321+ topic_score += penalty;
319322 #[ cfg( feature = "metrics" ) ]
320323 report
321324 . penalties
@@ -324,7 +327,7 @@ impl PeerScore {
324327 peer=%peer_id,
325328 %topic,
326329 %deficit,
327- penalty=%topic_score ,
330+ penalty=%penalty ,
328331 "[Penalty] The peer has a mesh deliveries deficit and will be penalized"
329332 ) ;
330333 }
@@ -367,7 +370,9 @@ impl PeerScore {
367370 // addr. It is quadratic, and the weight is negative (validated by
368371 // peer_score_params.validate()).
369372 if let Some ( peers_in_ip) = self . peer_ips . get ( ip) . map ( |peers| peers. len ( ) ) {
370- if ( peers_in_ip as f64 ) > self . params . ip_colocation_factor_threshold {
373+ if ( peers_in_ip as f64 ) > self . params . ip_colocation_factor_threshold
374+ && self . params . ip_colocation_factor_weight != 0.0
375+ {
371376 let surplus = ( peers_in_ip as f64 ) - self . params . ip_colocation_factor_threshold ;
372377 let p6 = surplus * surplus;
373378 #[ cfg( feature = "metrics" ) ]
0 commit comments