mirror of
https://github.com/threefoldtech/mycelium.git
synced 2026-05-28 03:14:26 +00:00
Use Peer instead of RouteKey in entry_mut
Signed-off-by: Lee Smet <lee.smet@hotmail.com>
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user