xfer
This commit is contained in:
		@@ -493,6 +493,10 @@ impl<'a> NodeRefLocked<'a> {
 | 
				
			|||||||
            nr,
 | 
					            nr,
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pub fn unlocked(&self) -> NodeRef {
 | 
				
			||||||
 | 
					        self.nr.clone()
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
impl<'a> NodeRefBase for NodeRefLocked<'a> {
 | 
					impl<'a> NodeRefBase for NodeRefLocked<'a> {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -338,8 +338,8 @@ impl RouteSpecStore {
 | 
				
			|||||||
            };
 | 
					            };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Pull the whole routing table in sorted order
 | 
					        // Pull the whole routing table in sorted order
 | 
				
			||||||
        let nodes =
 | 
					        let nodes:Vec<NodeRefLocked> =
 | 
				
			||||||
            rti.find_peers_with_sort_and_filter(usize::MAX, cur_ts, filters, compare, transform);
 | 
					            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 we couldn't find enough nodes, wait until we have more nodes in the routing table
 | 
				
			||||||
        if nodes.len() < hop_count {
 | 
					        if nodes.len() < hop_count {
 | 
				
			||||||
@@ -348,17 +348,17 @@ impl RouteSpecStore {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Get peer info for everything
 | 
					        // Get peer info for everything
 | 
				
			||||||
        let nodes_pi: Vec<PeerInfo> = nodes.iter().map(|nr| nr.locked(rti).make_peer_info(RoutingDomain::PublicInternet).unwrap()).collect();
 | 
					        let nodes_pi: Vec<PeerInfo> = 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
 | 
					        // Now go through nodes and try to build a route we haven't seen yet
 | 
				
			||||||
        let mut perm_func = Box::new(|permutation: &[usize]| {
 | 
					        let mut perm_func = Box::new(|permutation: &[usize]| {
 | 
				
			||||||
            
 | 
					            
 | 
				
			||||||
            /// Get the hop cache key for a particular route permutation
 | 
					            /// Get the hop cache key for a particular route permutation
 | 
				
			||||||
            /// uses the same algorithm as RouteSetSpecDetail::make_cache_key
 | 
					            /// uses the same algorithm as RouteSetSpecDetail::make_cache_key
 | 
				
			||||||
            fn route_permutation_to_hop_cache(rti: &RoutingTableInner, nodes: &[NodeRef], perm: &[usize]) -> Vec<u8> {
 | 
					            fn route_permutation_to_hop_cache(_rti: &RoutingTableInner, nodes: &[NodeRefLocked], perm: &[usize]) -> Vec<u8> {
 | 
				
			||||||
                let mut cache: Vec<u8> = Vec::with_capacity(perm.len() * PUBLIC_KEY_LENGTH);
 | 
					                let mut cache: Vec<u8> = Vec::with_capacity(perm.len() * PUBLIC_KEY_LENGTH);
 | 
				
			||||||
                for n in perm {
 | 
					                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
 | 
					                cache
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
@@ -372,13 +372,13 @@ impl RouteSpecStore {
 | 
				
			|||||||
            // Ensure the route doesn't contain both a node and its relay
 | 
					            // Ensure the route doesn't contain both a node and its relay
 | 
				
			||||||
            let mut seen_nodes: HashSet<TypedKey> = HashSet::new();
 | 
					            let mut seen_nodes: HashSet<TypedKey> = HashSet::new();
 | 
				
			||||||
            for n in permutation {
 | 
					            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()) {
 | 
					                if !seen_nodes.insert(node.best_node_id()) {
 | 
				
			||||||
                    // Already seen this node, should not be in the route twice
 | 
					                    // Already seen this node, should not be in the route twice
 | 
				
			||||||
                    return None;
 | 
					                    return None;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                if let Some(relay) = node.relay(RoutingDomain::PublicInternet) {
 | 
					                if let Some(relay) = node.relay(RoutingDomain::PublicInternet).map(|n| n.locked(rti)) {
 | 
				
			||||||
                    let relay_id = relay.locked(rti).best_node_id();
 | 
					                    let relay_id = relay.best_node_id();
 | 
				
			||||||
                    if !seen_nodes.insert(relay_id) {
 | 
					                    if !seen_nodes.insert(relay_id) {
 | 
				
			||||||
                        // Already seen this node, should not be in the route twice
 | 
					                        // Already seen this node, should not be in the route twice
 | 
				
			||||||
                        return None;
 | 
					                        return None;
 | 
				
			||||||
@@ -485,7 +485,7 @@ impl RouteSpecStore {
 | 
				
			|||||||
        // Got a unique route, lets build the details, register it, and return it
 | 
					        // Got a unique route, lets build the details, register it, and return it
 | 
				
			||||||
        let hop_node_refs:Vec<NodeRef> = route_nodes
 | 
					        let hop_node_refs:Vec<NodeRef> = route_nodes
 | 
				
			||||||
            .iter()
 | 
					            .iter()
 | 
				
			||||||
            .map(|k| nodes[*k].clone())
 | 
					            .map(|k| nodes[*k].unlocked())
 | 
				
			||||||
            .collect();
 | 
					            .collect();
 | 
				
			||||||
        let mut route_set = BTreeMap::<PublicKey, RouteSpecDetail>::new();
 | 
					        let mut route_set = BTreeMap::<PublicKey, RouteSpecDetail>::new();
 | 
				
			||||||
        for crypto_kind in crypto_kinds.iter().copied() {
 | 
					        for crypto_kind in crypto_kinds.iter().copied() {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -972,7 +972,7 @@ impl RoutingTableInner {
 | 
				
			|||||||
            &'b Option<Arc<BucketEntry>>,
 | 
					            &'b Option<Arc<BucketEntry>>,
 | 
				
			||||||
            &'b Option<Arc<BucketEntry>>,
 | 
					            &'b Option<Arc<BucketEntry>>,
 | 
				
			||||||
        ) -> core::cmp::Ordering,
 | 
					        ) -> core::cmp::Ordering,
 | 
				
			||||||
        T: for<'r> FnMut(&'r RoutingTableInner, Option<Arc<BucketEntry>>) -> O,
 | 
					        T: for<'r, 't> FnMut(&'r RoutingTableInner, Option<Arc<BucketEntry>>) -> O,
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        // collect all the nodes for sorting
 | 
					        // collect all the nodes for sorting
 | 
				
			||||||
        let mut nodes =
 | 
					        let mut nodes =
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user