diff --git a/veilid-core/src/routing_table/node_ref.rs b/veilid-core/src/routing_table/node_ref.rs index a00d014f..296486bc 100644 --- a/veilid-core/src/routing_table/node_ref.rs +++ b/veilid-core/src/routing_table/node_ref.rs @@ -493,6 +493,10 @@ impl<'a> NodeRefLocked<'a> { nr, } } + + pub fn unlocked(&self) -> NodeRef { + self.nr.clone() + } } impl<'a> NodeRefBase for NodeRefLocked<'a> { diff --git a/veilid-core/src/routing_table/route_spec_store/route_spec_store.rs b/veilid-core/src/routing_table/route_spec_store/route_spec_store.rs index 4b0d3e1f..e6ca0fc5 100644 --- a/veilid-core/src/routing_table/route_spec_store/route_spec_store.rs +++ b/veilid-core/src/routing_table/route_spec_store/route_spec_store.rs @@ -338,8 +338,8 @@ impl RouteSpecStore { }; // Pull the whole routing table in sorted order - let nodes = - rti.find_peers_with_sort_and_filter(usize::MAX, cur_ts, filters, compare, transform); + let nodes:Vec = + rti.find_peers_with_sort_and_filter(usize::MAX, cur_ts, filters, compare, transform).iter().map(|n| n.locked(rti)).collect(); // If we couldn't find enough nodes, wait until we have more nodes in the routing table if nodes.len() < hop_count { @@ -348,17 +348,17 @@ impl RouteSpecStore { } // Get peer info for everything - let nodes_pi: Vec = nodes.iter().map(|nr| nr.locked(rti).make_peer_info(RoutingDomain::PublicInternet).unwrap()).collect(); + let nodes_pi: Vec = nodes.iter().map(|nr| nr.make_peer_info(RoutingDomain::PublicInternet).unwrap()).collect(); // Now go through nodes and try to build a route we haven't seen yet let mut perm_func = Box::new(|permutation: &[usize]| { /// Get the hop cache key for a particular route permutation /// uses the same algorithm as RouteSetSpecDetail::make_cache_key - fn route_permutation_to_hop_cache(rti: &RoutingTableInner, nodes: &[NodeRef], perm: &[usize]) -> Vec { + fn route_permutation_to_hop_cache(_rti: &RoutingTableInner, nodes: &[NodeRefLocked], perm: &[usize]) -> Vec { let mut cache: Vec = Vec::with_capacity(perm.len() * PUBLIC_KEY_LENGTH); for n in perm { - cache.extend_from_slice(&nodes[*n].locked(rti).best_node_id().value.bytes) + cache.extend_from_slice(&nodes[*n].best_node_id().value.bytes) } cache } @@ -372,13 +372,13 @@ impl RouteSpecStore { // Ensure the route doesn't contain both a node and its relay let mut seen_nodes: HashSet = HashSet::new(); for n in permutation { - let node = nodes.get(*n).unwrap().locked_mut(rti); + let node = nodes.get(*n).unwrap(); if !seen_nodes.insert(node.best_node_id()) { // Already seen this node, should not be in the route twice return None; } - if let Some(relay) = node.relay(RoutingDomain::PublicInternet) { - let relay_id = relay.locked(rti).best_node_id(); + if let Some(relay) = node.relay(RoutingDomain::PublicInternet).map(|n| n.locked(rti)) { + let relay_id = relay.best_node_id(); if !seen_nodes.insert(relay_id) { // Already seen this node, should not be in the route twice return None; @@ -485,7 +485,7 @@ impl RouteSpecStore { // Got a unique route, lets build the details, register it, and return it let hop_node_refs:Vec = route_nodes .iter() - .map(|k| nodes[*k].clone()) + .map(|k| nodes[*k].unlocked()) .collect(); let mut route_set = BTreeMap::::new(); for crypto_kind in crypto_kinds.iter().copied() { diff --git a/veilid-core/src/routing_table/routing_table_inner.rs b/veilid-core/src/routing_table/routing_table_inner.rs index c5104ae7..40f2f30d 100644 --- a/veilid-core/src/routing_table/routing_table_inner.rs +++ b/veilid-core/src/routing_table/routing_table_inner.rs @@ -972,7 +972,7 @@ impl RoutingTableInner { &'b Option>, &'b Option>, ) -> core::cmp::Ordering, - T: for<'r> FnMut(&'r RoutingTableInner, Option>) -> O, + T: for<'r, 't> FnMut(&'r RoutingTableInner, Option>) -> O, { // collect all the nodes for sorting let mut nodes =