Skip to content

Commit 40bb41d

Browse files
jjyrdoitian
authored andcommitted
feat(network): Reduce unnessacery identify_protocol query
1 parent ff51a9c commit 40bb41d

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

network/src/identify_service.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ impl IdentifyService {
4747
client_version: info.agent_version.clone(),
4848
protocol_version: info.protocol_version.clone(),
4949
supported_protocols: info.protocols.clone(),
50+
count_of_known_listen_addrs: info.listen_addrs.len(),
5051
})
5152
}
5253
None => error!(
@@ -193,6 +194,11 @@ where
193194
move |_| {
194195
let peers_registry = network.peers_registry().read();
195196
for (peer_id, peer) in peers_registry.peers_iter() {
197+
if let Some(ref identify_info) = peer.identify_info {
198+
if identify_info.count_of_known_listen_addrs > 0 {
199+
continue;
200+
}
201+
}
196202
trace!(
197203
"request identify to peer {:?} {:?}",
198204
peer_id,

network/src/peers_registry.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ pub struct PeerIdentifyInfo {
8080
pub client_version: String,
8181
pub protocol_version: String,
8282
pub supported_protocols: Vec<String>,
83+
pub count_of_known_listen_addrs: usize,
8384
}
8485

8586
type ProtocolConnec = (ProtocolId, UniqueConnec<(UnboundedSender<Bytes>, u8)>);

0 commit comments

Comments
 (0)