refactor and change protocol selection for new connections
This commit is contained in:
		| @@ -317,7 +317,6 @@ impl BucketEntryInner { | ||||
|             rti, | ||||
|             true, | ||||
|             NodeRefFilter::from(routing_domain), | ||||
|             false, | ||||
|         ); | ||||
|         !last_connections.is_empty() | ||||
|     } | ||||
| @@ -372,7 +371,6 @@ impl BucketEntryInner { | ||||
|             rti, | ||||
|             true, | ||||
|             NodeRefFilter::from(routing_domain_set), | ||||
|             false | ||||
|         ); | ||||
|         for lc in last_connections { | ||||
|             if let Some(rd) = | ||||
| @@ -415,7 +413,6 @@ impl BucketEntryInner { | ||||
|         rti: &RoutingTableInner, | ||||
|         only_live: bool, | ||||
|         filter: NodeRefFilter, | ||||
|         ordered: bool, | ||||
|     ) -> Vec<(ConnectionDescriptor, Timestamp)> { | ||||
|         let connection_manager = | ||||
|             rti.unlocked_inner.network_manager.connection_manager(); | ||||
| @@ -461,14 +458,8 @@ impl BucketEntryInner { | ||||
|                 } | ||||
|             }) | ||||
|             .collect(); | ||||
|         // Sort with ordering preference first and then sort with newest timestamps | ||||
|         // Sort with newest timestamps | ||||
|         out.sort_by(|a, b| { | ||||
|             if ordered { | ||||
|                 let s = ProtocolType::ordered_sequencing_sort(a.0.protocol_type(), b.0.protocol_type()); | ||||
|                 if s != core::cmp::Ordering::Equal { | ||||
|                     return s; | ||||
|                 } | ||||
|             } | ||||
|             b.1.cmp(&a.1) | ||||
|         }); | ||||
|         out | ||||
|   | ||||
| @@ -277,15 +277,22 @@ pub trait NodeRefBase: Sized { | ||||
|         out | ||||
|     } | ||||
|  | ||||
|     /// Get the most recent 'last connection' to this node | ||||
|     /// Filtered first and then sorted by ordering preference and then by most recent | ||||
|     fn last_connection(&self) -> Option<ConnectionDescriptor> { | ||||
|         // Get the last connections and the last time we saw anything with this connection | ||||
|         // Filtered first and then sorted by sequencing and then by most recent | ||||
|         self.operate(|rti, e| { | ||||
|             // apply sequencing to filter and get sort | ||||
|             let sequencing = self.common().sequencing; | ||||
|             let filter = self.common().filter.clone().unwrap_or_default(); | ||||
|             let (ordered, filter) = filter.with_sequencing(sequencing); | ||||
|             let last_connections = e.last_connections(rti, true, filter, ordered); | ||||
|             let mut last_connections = e.last_connections(rti, true, filter); | ||||
|  | ||||
|             if ordered { | ||||
|                 last_connections.sort_by(|a, b| { | ||||
|                     ProtocolType::ordered_sequencing_sort(a.0.protocol_type(), b.0.protocol_type()) | ||||
|                 }); | ||||
|             } | ||||
|  | ||||
|             last_connections.first().map(|x| x.0) | ||||
|         }) | ||||
|     } | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| use super::*; | ||||
|  | ||||
| #[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord)] | ||||
| #[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] | ||||
| pub struct NodeRefFilter { | ||||
|     pub routing_domain_set: RoutingDomainSet, | ||||
|     pub dial_info_filter: DialInfoFilter, | ||||
|   | ||||
		Reference in New Issue
	
	Block a user