|
|
|
@ -1,6 +1,6 @@ |
|
|
|
use crate::{ |
|
|
|
use crate::{ |
|
|
|
client_server::{self, claim_keys_helper, get_keys_helper}, |
|
|
|
client_server::{self, claim_keys_helper, get_keys_helper}, |
|
|
|
database::DatabaseGuard, |
|
|
|
database::{abstraction::sqlite::MILLI, DatabaseGuard}, |
|
|
|
utils, ConduitResult, Database, Error, PduEvent, Result, Ruma, |
|
|
|
utils, ConduitResult, Database, Error, PduEvent, Result, Ruma, |
|
|
|
}; |
|
|
|
}; |
|
|
|
use get_profile_information::v1::ProfileField; |
|
|
|
use get_profile_information::v1::ProfileField; |
|
|
|
@ -1732,7 +1732,12 @@ fn get_auth_chain(starting_events: Vec<EventId>, db: &Database) -> Result<HashSe |
|
|
|
cached.clone() |
|
|
|
cached.clone() |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
drop(cache); |
|
|
|
drop(cache); |
|
|
|
|
|
|
|
let start = Instant::now(); |
|
|
|
let auth_chain = get_auth_chain_recursive(&event_id, HashSet::new(), db)?; |
|
|
|
let auth_chain = get_auth_chain_recursive(&event_id, HashSet::new(), db)?; |
|
|
|
|
|
|
|
let elapsed = start.elapsed(); |
|
|
|
|
|
|
|
if elapsed > MILLI { |
|
|
|
|
|
|
|
println!("auth chain for {} took {:?}", &event_id, elapsed) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
cache = db.rooms.auth_chain_cache(); |
|
|
|
cache = db.rooms.auth_chain_cache(); |
|
|
|
|
|
|
|
|
|
|
|
@ -1747,7 +1752,11 @@ fn get_auth_chain(starting_events: Vec<EventId>, db: &Database) -> Result<HashSe |
|
|
|
Ok(full_auth_chain) |
|
|
|
Ok(full_auth_chain) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fn get_auth_chain_recursive(event_id: &EventId, mut found: HashSet<EventId>, db: &Database) -> Result<HashSet<EventId>> { |
|
|
|
fn get_auth_chain_recursive( |
|
|
|
|
|
|
|
event_id: &EventId, |
|
|
|
|
|
|
|
mut found: HashSet<EventId>, |
|
|
|
|
|
|
|
db: &Database, |
|
|
|
|
|
|
|
) -> Result<HashSet<EventId>> { |
|
|
|
if let Some(pdu) = db.rooms.get_pdu(&event_id)? { |
|
|
|
if let Some(pdu) = db.rooms.get_pdu(&event_id)? { |
|
|
|
for auth_event in &pdu.auth_events { |
|
|
|
for auth_event in &pdu.auth_events { |
|
|
|
if !found.contains(auth_event) { |
|
|
|
if !found.contains(auth_event) { |
|
|
|
|