From 68cc743f2a42a4f4155298a6231c48091aa401d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20K=C3=B6sters?= Date: Tue, 20 Jul 2021 18:45:21 +0200 Subject: [PATCH] fix: use get_auth_chain method more often --- src/client_server/sync.rs | 3 ++- src/server_server.rs | 22 +--------------------- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/client_server/sync.rs b/src/client_server/sync.rs index 7ab27d91..427b9add 100644 --- a/src/client_server/sync.rs +++ b/src/client_server/sync.rs @@ -267,7 +267,8 @@ async fn sync_helper( Error::bad_database("Found PDU without state") }) }) - .transpose()?.transpose()?; + .transpose()? + .transpose()?; // Calculates joined_member_count, invited_member_count and heroes let calculate_counts = || { diff --git a/src/server_server.rs b/src/server_server.rs index e463bba2..d51b672e 100644 --- a/src/server_server.rs +++ b/src/server_server.rs @@ -2198,27 +2198,7 @@ pub async fn create_join_event_route( drop(mutex_lock); let state_ids = db.rooms.state_full_ids(shortstatehash)?; - - let mut auth_chain_ids = HashSet::::new(); - let mut todo = state_ids.iter().cloned().collect::>(); - - while let Some(event_id) = todo.iter().next().cloned() { - if let Some(pdu) = db.rooms.get_pdu(&event_id)? { - todo.extend( - pdu.auth_events - .clone() - .into_iter() - .collect::>() - .difference(&auth_chain_ids) - .cloned(), - ); - auth_chain_ids.extend(pdu.auth_events.clone().into_iter()); - } else { - warn!("Could not find pdu mentioned in auth events."); - } - - todo.remove(&event_id); - } + let auth_chain_ids = get_auth_chain(state_ids.iter().cloned().collect(), &db)?; for server in db .rooms