Skip to content

Commit

Permalink
feat(network): Reduce unnessacery identify_protocol query
Browse files Browse the repository at this point in the history
  • Loading branch information
jjyr authored and doitian committed Nov 19, 2018
1 parent ff51a9c commit 40bb41d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions network/src/identify_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ impl IdentifyService {
client_version: info.agent_version.clone(),
protocol_version: info.protocol_version.clone(),
supported_protocols: info.protocols.clone(),
count_of_known_listen_addrs: info.listen_addrs.len(),
})
}
None => error!(
Expand Down Expand Up @@ -193,6 +194,11 @@ where
move |_| {
let peers_registry = network.peers_registry().read();
for (peer_id, peer) in peers_registry.peers_iter() {
if let Some(ref identify_info) = peer.identify_info {
if identify_info.count_of_known_listen_addrs > 0 {
continue;
}
}
trace!(
"request identify to peer {:?} {:?}",
peer_id,
Expand Down
1 change: 1 addition & 0 deletions network/src/peers_registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ pub struct PeerIdentifyInfo {
pub client_version: String,
pub protocol_version: String,
pub supported_protocols: Vec<String>,
pub count_of_known_listen_addrs: usize,
}

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

0 comments on commit 40bb41d

Please sign in to comment.