Use Peer instead of RouteKey in entry_mut

Signed-off-by: Lee Smet <lee.smet@hotmail.com>
This commit is contained in:
Lee Smet
2024-07-03 11:59:58 +02:00
parent 906d8f2d85
commit 459de51493
2 changed files with 4 additions and 7 deletions
+2 -2
View File
@@ -411,7 +411,7 @@ where
let mut routes = self.routing_table.routes_mut(rk.subnet());
// Bit of weird scoping for the mutable reference to entries.
let was_selected = {
let entry = routes.entry_mut(&rk);
let entry = routes.entry_mut(rk.neighbour());
if entry.is_none() {
continue;
}
@@ -985,7 +985,7 @@ where
// potentially mutate the route list so we can't keep a reference to it.
let old_selected_route = routing_table_entries.selected().cloned();
let maybe_existing_entry = routing_table_entries.entry_mut(&update_route_key);
let maybe_existing_entry = routing_table_entries.entry_mut(&source_peer);
debug!(
subnet = %subnet,
+2 -5
View File
@@ -505,15 +505,12 @@ impl<'a> RoutingTableReadGuard<'a> {
impl<'a> WriteGuard<'a> {
/// Get [`RouteEntryGuard`] containing a [`RouteEntry`] for the given [`RouteKey`].
pub fn entry_mut<'b>(
&'b mut self,
route_key: &RouteKey,
) -> RouteEntryGuard<'a, 'b, PossiblyEmpty> {
pub fn entry_mut<'b>(&'b mut self, neighbour: &Peer) -> RouteEntryGuard<'a, 'b, PossiblyEmpty> {
let entry_identifier = if let Some(pos) = self
.list
.iter_mut()
.map(|(_, e)| e)
.position(|entry| entry.neighbour() == route_key.neighbour())
.position(|entry| entry.neighbour() == neighbour)
{
EntryIdentifier::Pos(pos)
} else {