Skip to content

Commit

Permalink
reorganize
Browse files Browse the repository at this point in the history
  • Loading branch information
drHuangMHT committed Jan 5, 2025
1 parent ee09b51 commit 135cc97
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions protocols/gossipsub/src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1829,23 +1829,23 @@ where
if let Some(metrics) = self.metrics.as_mut() {
metrics.register_invalid_message(topic_hash);
}
if let Some(msg_id) = message_id {
// Valid transformation without peer scoring
self.gossip_promises.reject_message(msg_id, &reject_reason);
}
if let Some((peer_score, ..)) = &mut self.peer_score {
// The compiler will optimize this pattern-matching
if let Some(msg_id) = message_id {
peer_score.reject_message(propagation_source, msg_id, topic_hash, reject_reason);
// The message itself is valid, but is from a banned peer or
// claiming to be self-origin but is actually forwarded from other peers.
return self.gossip_promises.reject_message(msg_id, &reject_reason);
peer_score.reject_message(propagation_source, msg_id, topic_hash, reject_reason);
} else {
// The message is invalid, we reject it ignoring any gossip promises. If a peer is
// advertising this message via an IHAVE and it's invalid it will be double
// penalized, one for sending us an invalid and again for breaking a promise.
return peer_score.reject_invalid_message(propagation_source, topic_hash);
peer_score.reject_invalid_message(propagation_source, topic_hash);
}
}
if let Some(msg_id) = message_id {
// Valid transformation without peer scoring
self.gossip_promises.reject_message(msg_id, &reject_reason);
}
}

/// Handles received subscriptions.
Expand Down

0 comments on commit 135cc97

Please sign in to comment.