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")?, | ||||
|                 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")?, | ||||
|  |  | |||
|  | @ -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::<StateMap<_>>() | ||||
|                     }) | ||||
|                     .collect::<Vec<_>>(), | ||||
|                 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 { | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue