|
|
|
@ -3,7 +3,12 @@ mod edus; |
|
|
|
pub use edus::RoomEdus; |
|
|
|
pub use edus::RoomEdus; |
|
|
|
use member::MembershipState; |
|
|
|
use member::MembershipState; |
|
|
|
|
|
|
|
|
|
|
|
use crate::{pdu::PduBuilder, server_server, utils, Database, Error, PduEvent, Result}; |
|
|
|
use crate::{ |
|
|
|
|
|
|
|
pdu::PduBuilder, |
|
|
|
|
|
|
|
server_server, |
|
|
|
|
|
|
|
utils::{self, ArcingLruCache}, |
|
|
|
|
|
|
|
Database, Error, PduEvent, Result, |
|
|
|
|
|
|
|
}; |
|
|
|
use lru_cache::LruCache; |
|
|
|
use lru_cache::LruCache; |
|
|
|
use regex::Regex; |
|
|
|
use regex::Regex; |
|
|
|
use ring::digest; |
|
|
|
use ring::digest; |
|
|
|
@ -96,7 +101,7 @@ pub struct Rooms { |
|
|
|
/// RoomId + EventId -> Parent PDU EventId.
|
|
|
|
/// RoomId + EventId -> Parent PDU EventId.
|
|
|
|
pub(super) referencedevents: Arc<dyn Tree>, |
|
|
|
pub(super) referencedevents: Arc<dyn Tree>, |
|
|
|
|
|
|
|
|
|
|
|
pub(super) pdu_cache: Mutex<LruCache<EventId, Arc<PduEvent>>>, |
|
|
|
pub(super) pdu_cache: Mutex<ArcingLruCache<EventId, PduEvent>>, |
|
|
|
pub(super) shorteventid_cache: Mutex<LruCache<u64, Arc<EventId>>>, |
|
|
|
pub(super) shorteventid_cache: Mutex<LruCache<u64, Arc<EventId>>>, |
|
|
|
pub(super) auth_chain_cache: Mutex<LruCache<Vec<u64>, Arc<HashSet<u64>>>>, |
|
|
|
pub(super) auth_chain_cache: Mutex<LruCache<Vec<u64>, Arc<HashSet<u64>>>>, |
|
|
|
pub(super) eventidshort_cache: Mutex<LruCache<EventId, u64>>, |
|
|
|
pub(super) eventidshort_cache: Mutex<LruCache<EventId, u64>>, |
|
|
|
@ -1081,8 +1086,8 @@ impl Rooms { |
|
|
|
/// Checks the `eventid_outlierpdu` Tree if not found in the timeline.
|
|
|
|
/// Checks the `eventid_outlierpdu` Tree if not found in the timeline.
|
|
|
|
#[tracing::instrument(skip(self))] |
|
|
|
#[tracing::instrument(skip(self))] |
|
|
|
pub fn get_pdu(&self, event_id: &EventId) -> Result<Option<Arc<PduEvent>>> { |
|
|
|
pub fn get_pdu(&self, event_id: &EventId) -> Result<Option<Arc<PduEvent>>> { |
|
|
|
if let Some(p) = self.pdu_cache.lock().unwrap().get_mut(&event_id) { |
|
|
|
if let Some(p) = self.pdu_cache.lock().unwrap().get(&event_id as &EventId) { |
|
|
|
return Ok(Some(Arc::clone(p))); |
|
|
|
return Ok(Some(p)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if let Some(pdu) = self |
|
|
|
if let Some(pdu) = self |
|
|
|
|