Skip to content

Commit

Permalink
treat peers that do not support the protocol as disconnected (libp2p#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
blacktemplar authored Aug 12, 2020
1 parent 7bdb378 commit 83280db
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions protocols/gossipsub/src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2459,9 +2459,10 @@ impl NetworkBehaviour for Gossipsub {
) {
match handler_event {
HandlerEvent::PeerKind(kind) => {
//TODO: There is now a PeerKind::NotSupported. This happens if the peer doesn't
//support gossipsub.
if let Some(old_kind) = self.peer_protocols.get_mut(&propagation_source) {
if let PeerKind::NotSupported = kind {
//we treat this peer as disconnected
self.inject_disconnected(&propagation_source);
} else if let Some(old_kind) = self.peer_protocols.get_mut(&propagation_source) {
// Only change the value if the old value is Floodsub (the default set in
// inject_connected). All other PeerKind changes are ignored.
if let PeerKind::Floodsub = *old_kind {
Expand Down

0 comments on commit 83280db

Please sign in to comment.