-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
discovery: append quic multiaddrs along with tcp, #6
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -341,8 +341,9 @@ impl<AppReqId: ReqId, TSpec: EthSpec> Network<AppReqId, TSpec> { | |
|
||
let (swarm, bandwidth) = { | ||
// Set up the transport - tcp/ws with noise and mplex | ||
let (transport, bandwidth) = build_transport(local_keypair.clone(), !config.disable_quic_support) | ||
.map_err(|e| format!("Failed to build transport: {:?}", e))?; | ||
let (transport, bandwidth) = | ||
build_transport(local_keypair.clone(), !config.disable_quic_support) | ||
.map_err(|e| format!("Failed to build transport: {:?}", e))?; | ||
|
||
// use the executor for libp2p | ||
struct Executor(task_executor::TaskExecutor); | ||
|
@@ -400,7 +401,6 @@ impl<AppReqId: ReqId, TSpec: EthSpec> Network<AppReqId, TSpec> { | |
debug!(self.log, "Attempting to open listening ports"; config.listen_addrs(), "discovery_enabled" => !config.disable_discovery, "quic_enabled" => !config.disable_quic_support); | ||
|
||
for listen_multiaddr in config.listen_addrs().listen_addresses() { | ||
|
||
// If QUIC is disabled, ignore listening on QUIC ports | ||
if config.disable_quic_support { | ||
if listen_multiaddr.iter().any(|v| v == MProtocol::QuicV1) { | ||
|
@@ -1049,27 +1049,26 @@ impl<AppReqId: ReqId, TSpec: EthSpec> Network<AppReqId, TSpec> { | |
/// in Connected, Dialing or Banned state. | ||
fn dial_cached_enrs_in_subnet(&mut self, subnet: Subnet) { | ||
let predicate = subnet_predicate::<TSpec>(vec![subnet], &self.log); | ||
let peers_to_dial: Vec<PeerId> = self | ||
let peers_to_dial: Vec<Enr> = self | ||
.discovery() | ||
.cached_enrs() | ||
.filter_map(|(peer_id, enr)| { | ||
let peers = self.network_globals.peers.read(); | ||
if predicate(enr) && peers.should_dial(peer_id) { | ||
Some(*peer_id) | ||
Some(enr.clone()) | ||
} else { | ||
None | ||
} | ||
}) | ||
.collect(); | ||
for peer_id in peers_to_dial { | ||
debug!(self.log, "Dialing cached ENR peer"; "peer_id" => %peer_id); | ||
// Remove the ENR from the cache to prevent continual re-dialing on disconnects | ||
|
||
self.discovery_mut().remove_cached_enr(&peer_id); | ||
// For any dial event, inform the peer manager | ||
let enr = self.discovery_mut().enr_of_peer(&peer_id); | ||
self.peer_manager_mut().dial_peer(&peer_id, enr); | ||
} | ||
|
||
// Remove the ENR from the cache to prevent continual re-dialing on disconnects | ||
// TODO: add this step to the iteration above. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll add this guy also There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is a bit trickier because the iterator is on a reference of cached peers. The second iteration isn't that bad. Feel free to update if you find a nice way to group them and avoid the ENR clone |
||
peers_to_dial.iter().for_each(|enr| { | ||
self.discovery_mut().remove_cached_enr(&enr.peer_id()); | ||
}); | ||
|
||
self.peer_manager_mut().dial_peers(peers_to_dial); | ||
} | ||
|
||
/* Sub-behaviour event handling functions */ | ||
|
@@ -1359,14 +1358,9 @@ impl<AppReqId: ReqId, TSpec: EthSpec> Network<AppReqId, TSpec> { | |
&mut self, | ||
event: DiscoveredPeers, | ||
) -> Option<NetworkEvent<AppReqId, TSpec>> { | ||
let DiscoveredPeers { peers } = event; | ||
let to_dial_peers = self.peer_manager_mut().peers_discovered(peers); | ||
for peer_id in to_dial_peers { | ||
debug!(self.log, "Dialing discovered peer"; "peer_id" => %peer_id); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Some of the logs we emit are quite important. Trace logs not so much, but debug logs are. This one in particular is very useful to track errors throughout the stack as we note when we dial and when connections fail etc. I'll add this log into the peer manager poll when we submit the actual dial. |
||
// For any dial event, inform the peer manager | ||
let enr = self.discovery_mut().enr_of_peer(&peer_id); | ||
self.peer_manager_mut().dial_peer(&peer_id, enr); | ||
} | ||
let to_dial_peers = self.peer_manager_mut().peers_discovered(event.peers); | ||
// For any dial event, inform the peer manager | ||
self.peer_manager_mut().dial_peers(to_dial_peers); | ||
None | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice. I'll also update the doc comments to match