Skip to content

Commit ff870d3

Browse files
committed
inlined identify
1 parent aaffc3c commit ff870d3

File tree

1 file changed

+13
-20
lines changed

1 file changed

+13
-20
lines changed

p2p/src/client.rs

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,19 @@ impl DriaP2PClient {
232232
peer_id,
233233
info,
234234
..
235-
})) => self.handle_identify_event(peer_id, info),
235+
})) => {
236+
if info.protocol_version != self.protocol.identity {
237+
log::warn!(
238+
"Identify: Peer {} has different Identify protocol: (them {}, you {})",
239+
peer_id,
240+
info.protocol_version,
241+
self.protocol.identity
242+
);
243+
244+
// disconnect them
245+
let _ = self.swarm.disconnect_peer_id(peer_id);
246+
}
247+
}
236248

237249
/*****************************************
238250
* Connection events and errors handling *
@@ -337,23 +349,4 @@ impl DriaP2PClient {
337349
event => log::debug!("Unhandled Swarm Event: {:?}", event),
338350
}
339351
}
340-
341-
/// Handles identify events.
342-
///
343-
/// At the top level, we check the protocol string.
344-
///
345-
/// - For Kademlia, we check the kademlia protocol and then add the address to the Kademlia routing table.
346-
fn handle_identify_event(&mut self, peer_id: PeerId, info: identify::Info) {
347-
if info.protocol_version != self.protocol.identity {
348-
log::warn!(
349-
"Identify: Peer {} has different Identify protocol: (them {}, you {})",
350-
peer_id,
351-
info.protocol_version,
352-
self.protocol.identity
353-
);
354-
355-
// disconnect them
356-
let _ = self.swarm.disconnect_peer_id(peer_id);
357-
}
358-
}
359352
}

0 commit comments

Comments
 (0)