diff --git a/src/database.rs b/src/database.rs index b32f539..1fd963b 100644 --- a/src/database.rs +++ b/src/database.rs @@ -279,7 +279,7 @@ impl Database { eventid_outlierpdu: builder.open_tree("eventid_outlierpdu")?, prevevent_parent: builder.open_tree("prevevent_parent")?, - pdu_cache: RwLock::new(LruCache::new(1_000_000)), + pdu_cache: RwLock::new(LruCache::new(10_000)), }, account_data: account_data::AccountData { roomuserdataid_accountdata: builder.open_tree("roomuserdataid_accountdata")?, diff --git a/src/server_server.rs b/src/server_server.rs index 25cdd99..458e32d 100644 --- a/src/server_server.rs +++ b/src/server_server.rs @@ -46,7 +46,7 @@ use ruma::{ receipt::ReceiptType, serde::Raw, signatures::{CanonicalJsonObject, CanonicalJsonValue}, - state_res::{self, Event, RoomVersion, StateMap}, + state_res::{self, RoomVersion, StateMap}, to_device::DeviceIdOrAllDevices, uint, EventId, MilliSecondsSinceUnixEpoch, RoomId, RoomVersionId, ServerName, ServerSigningKeyId, UserId, @@ -1219,18 +1219,10 @@ pub fn handle_incoming_pdu<'a>( let mut auth_events = vec![]; for map in &fork_states { - let mut state_auth = vec![]; - for auth_id in map.values().flat_map(|pdu| &pdu.auth_events) { - match fetch_and_handle_events(&db, origin, &[auth_id.clone()], pub_key_map) - .await - { - // This should always contain exactly one element when Ok - Ok(events) => state_auth.extend_from_slice(&events), - Err(e) => { - debug!("Event was not present: {}", e); - } - } - } + let state_auth = map + .values() + .flat_map(|pdu| pdu.auth_events.clone()) + .collect(); auth_events.push(state_auth); } @@ -1245,10 +1237,7 @@ pub fn handle_incoming_pdu<'a>( .collect::>() }) .collect::>(), - auth_events - .into_iter() - .map(|pdus| pdus.into_iter().map(|pdu| pdu.event_id().clone()).collect()) - .collect(), + auth_events, &|id| { let res = db.rooms.get_pdu(id); if let Err(e) = &res {