improvement: less IO for auth chains
parent
33172a70e6
commit
a1e8a99db5
|
@ -1980,15 +1980,9 @@ fn get_auth_chain(
|
||||||
let mut buckets = vec![BTreeSet::new(); NUM_BUCKETS];
|
let mut buckets = vec![BTreeSet::new(); NUM_BUCKETS];
|
||||||
|
|
||||||
for id in starting_events {
|
for id in starting_events {
|
||||||
if let Some(pdu) = db.rooms.get_pdu(&id)? {
|
let short = db.rooms.get_or_create_shorteventid(&id, &db.globals)?;
|
||||||
for auth_event in &pdu.auth_events {
|
let bucket_id = (short % NUM_BUCKETS as u64) as usize;
|
||||||
let short = db
|
buckets[bucket_id].insert((short, id.clone()));
|
||||||
.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 mut full_auth_chain = HashSet::new();
|
let mut full_auth_chain = HashSet::new();
|
||||||
|
@ -2000,10 +1994,6 @@ fn get_auth_chain(
|
||||||
continue;
|
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
|
let chunk_key = chunk
|
||||||
.iter()
|
.iter()
|
||||||
.map(|(short, _)| short)
|
.map(|(short, _)| short)
|
||||||
|
|
Loading…
Reference in New Issue