handle peerinfo better

This commit is contained in:
Christien Rioux 2024-06-30 13:52:38 -04:00
parent aeebe2a596
commit 4d4e447132
2 changed files with 8 additions and 5 deletions

View File

@ -753,9 +753,13 @@ impl NetworkManager {
.get_outbound_node_ref_filter(RoutingDomain::PublicInternet) .get_outbound_node_ref_filter(RoutingDomain::PublicInternet)
.with_protocol_type(ProtocolType::UDP); .with_protocol_type(ProtocolType::UDP);
peer_nr.set_filter(Some(outbound_nrf)); peer_nr.set_filter(Some(outbound_nrf));
let hole_punch_dial_info_detail = peer_nr let Some(hole_punch_dial_info_detail) = peer_nr.first_filtered_dial_info_detail()
.first_filtered_dial_info_detail() else {
.ok_or_else(|| eyre!("No hole punch capable dialinfo found for node"))?; return Ok(NetworkResult::no_connection_other(format!(
"No hole punch capable dialinfo found for node: {}",
peer_nr
)));
};
// Now that we picked a specific dialinfo, further restrict the noderef to the specific address type // Now that we picked a specific dialinfo, further restrict the noderef to the specific address type
let filter = peer_nr.take_filter().unwrap(); let filter = peer_nr.take_filter().unwrap();

View File

@ -22,7 +22,7 @@ impl RoutingTable {
// find N nodes closest to the target node in our routing table // find N nodes closest to the target node in our routing table
let own_peer_info = self.get_own_peer_info(RoutingDomain::PublicInternet); let own_peer_info = self.get_own_peer_info(RoutingDomain::PublicInternet);
let filter = Box::new( let filter = Box::new(
move |rti: &RoutingTableInner, opt_entry: Option<Arc<BucketEntry>>| { |rti: &RoutingTableInner, opt_entry: Option<Arc<BucketEntry>>| {
// Ensure only things that are valid/signed in the PublicInternet domain are returned // Ensure only things that are valid/signed in the PublicInternet domain are returned
if !rti.filter_has_valid_signed_node_info( if !rti.filter_has_valid_signed_node_info(
RoutingDomain::PublicInternet, RoutingDomain::PublicInternet,
@ -50,7 +50,6 @@ impl RoutingTable {
c.network.dht.max_find_node_count as usize c.network.dht.max_find_node_count as usize
}; };
let own_peer_info = self.get_own_peer_info(RoutingDomain::PublicInternet);
let closest_nodes = match self.find_preferred_closest_nodes( let closest_nodes = match self.find_preferred_closest_nodes(
node_count, node_count,
key, key,