mirror of
https://gitlab.com/famedly/conduit.git
synced 2024-12-29 09:24:42 +01:00
improvement: more efficient state res
This commit is contained in:
parent
f3e806096b
commit
ac0027756e
2 changed files with 7 additions and 18 deletions
|
@ -279,7 +279,7 @@ impl Database {
|
||||||
|
|
||||||
eventid_outlierpdu: builder.open_tree("eventid_outlierpdu")?,
|
eventid_outlierpdu: builder.open_tree("eventid_outlierpdu")?,
|
||||||
prevevent_parent: builder.open_tree("prevevent_parent")?,
|
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 {
|
account_data: account_data::AccountData {
|
||||||
roomuserdataid_accountdata: builder.open_tree("roomuserdataid_accountdata")?,
|
roomuserdataid_accountdata: builder.open_tree("roomuserdataid_accountdata")?,
|
||||||
|
|
|
@ -46,7 +46,7 @@ use ruma::{
|
||||||
receipt::ReceiptType,
|
receipt::ReceiptType,
|
||||||
serde::Raw,
|
serde::Raw,
|
||||||
signatures::{CanonicalJsonObject, CanonicalJsonValue},
|
signatures::{CanonicalJsonObject, CanonicalJsonValue},
|
||||||
state_res::{self, Event, RoomVersion, StateMap},
|
state_res::{self, RoomVersion, StateMap},
|
||||||
to_device::DeviceIdOrAllDevices,
|
to_device::DeviceIdOrAllDevices,
|
||||||
uint, EventId, MilliSecondsSinceUnixEpoch, RoomId, RoomVersionId, ServerName,
|
uint, EventId, MilliSecondsSinceUnixEpoch, RoomId, RoomVersionId, ServerName,
|
||||||
ServerSigningKeyId, UserId,
|
ServerSigningKeyId, UserId,
|
||||||
|
@ -1219,18 +1219,10 @@ pub fn handle_incoming_pdu<'a>(
|
||||||
|
|
||||||
let mut auth_events = vec![];
|
let mut auth_events = vec![];
|
||||||
for map in &fork_states {
|
for map in &fork_states {
|
||||||
let mut state_auth = vec![];
|
let state_auth = map
|
||||||
for auth_id in map.values().flat_map(|pdu| &pdu.auth_events) {
|
.values()
|
||||||
match fetch_and_handle_events(&db, origin, &[auth_id.clone()], pub_key_map)
|
.flat_map(|pdu| pdu.auth_events.clone())
|
||||||
.await
|
.collect();
|
||||||
{
|
|
||||||
// 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
auth_events.push(state_auth);
|
auth_events.push(state_auth);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1245,10 +1237,7 @@ pub fn handle_incoming_pdu<'a>(
|
||||||
.collect::<StateMap<_>>()
|
.collect::<StateMap<_>>()
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>(),
|
.collect::<Vec<_>>(),
|
||||||
auth_events
|
auth_events,
|
||||||
.into_iter()
|
|
||||||
.map(|pdus| pdus.into_iter().map(|pdu| pdu.event_id().clone()).collect())
|
|
||||||
.collect(),
|
|
||||||
&|id| {
|
&|id| {
|
||||||
let res = db.rooms.get_pdu(id);
|
let res = db.rooms.get_pdu(id);
|
||||||
if let Err(e) = &res {
|
if let Err(e) = &res {
|
||||||
|
|
Loading…
Reference in a new issue