Skip to content

Commit 4b04c2d

Browse files
committed
address Diego's review
1 parent db42038 commit 4b04c2d

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

protocols/gossipsub/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
- Remove `Rpc` from the public API.
66
See [PR 6091](https://github.com/libp2p/rust-libp2p/pull/6091)
77

8+
- Report peers with Low scores.
9+
See [PR XXXX](https://github.com/libp2p/rust-libp2p/pull/6091)
10+
811
## 0.49.2
912

1013
- Relax `Behaviour::with_metrics` requirements, do not require DataTransform and TopicSubscriptionFilter to also impl Default

protocols/gossipsub/src/behaviour.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ pub enum Event {
165165
failed_messages: FailedMessages,
166166
},
167167
/// A Peer is below the score threshold.
168-
LowScorePeers { peer_ids: Vec<PeerId> },
168+
BelowThresholdPeers { peer_ids: Vec<PeerId> },
169169
}
170170

171171
/// A data structure for storing configuration for publishing messages. See [`MessageAuthenticity`]
@@ -2178,7 +2178,7 @@ where
21782178

21792179
if !peers_to_report.is_empty() {
21802180
self.events
2181-
.push_back(ToSwarm::GenerateEvent(Event::LowScorePeers {
2181+
.push_back(ToSwarm::GenerateEvent(Event::BelowThresholdPeers {
21822182
peer_ids: peers_to_report,
21832183
}));
21842184
}

protocols/gossipsub/src/behaviour/tests.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6826,11 +6826,16 @@ fn test_low_score_peer_is_reported() {
68266826
let low_score_event = gs
68276827
.events
68286828
.iter()
6829-
.find(|event| matches!(event, ToSwarm::GenerateEvent(Event::LowScorePeers { .. })))
6829+
.find(|event| {
6830+
matches!(
6831+
event,
6832+
ToSwarm::GenerateEvent(Event::BelowThresholdPeers { .. })
6833+
)
6834+
})
68306835
.unwrap();
68316836

68326837
match low_score_event {
6833-
ToSwarm::GenerateEvent(Event::LowScorePeers { peer_ids }) => {
6838+
ToSwarm::GenerateEvent(Event::BelowThresholdPeers { peer_ids }) => {
68346839
assert_eq!(peer_ids.len(), 2);
68356840
assert!(peer_ids.contains(&peers[0]));
68366841
assert!(peer_ids.contains(&peers[1]));

0 commit comments

Comments
 (0)