From a1e8a99db57a1db11fdec59cad9d77cbdeed04b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20K=C3=B6sters?= Date: Thu, 26 Aug 2021 18:59:38 +0200 Subject: [PATCH] improvement: less IO for auth chains --- src/server_server.rs | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/src/server_server.rs b/src/server_server.rs index 65fd4a85..77941240 100644 --- a/src/server_server.rs +++ b/src/server_server.rs @@ -1980,15 +1980,9 @@ fn get_auth_chain( let mut buckets = vec![BTreeSet::new(); NUM_BUCKETS]; for id in starting_events { - if let Some(pdu) = db.rooms.get_pdu(&id)? { - for auth_event in &pdu.auth_events { - let short = db - .rooms - .get_or_create_shorteventid(&auth_event, &db.globals)?; - let bucket_id = (short % NUM_BUCKETS as u64) as usize; - buckets[bucket_id].insert((short, auth_event.clone())); - } - } + let short = db.rooms.get_or_create_shorteventid(&id, &db.globals)?; + let bucket_id = (short % NUM_BUCKETS as u64) as usize; + buckets[bucket_id].insert((short, id.clone())); } let mut full_auth_chain = HashSet::new(); @@ -2000,10 +1994,6 @@ fn get_auth_chain( continue; } - // The code below will only get the auth chains, not the events in the chunk. So let's add - // them first - full_auth_chain.extend(chunk.iter().map(|(id, _)| id)); - let chunk_key = chunk .iter() .map(|(short, _)| short)