|
|
|
@ -668,7 +668,7 @@ pub async fn send_transaction_message_route( |
|
|
|
|
|
|
|
|
|
|
|
let elapsed = start_time.elapsed(); |
|
|
|
let elapsed = start_time.elapsed(); |
|
|
|
warn!( |
|
|
|
warn!( |
|
|
|
"Handling event {} took {}m{}s", |
|
|
|
"Handling transaction of event {} took {}m{}s", |
|
|
|
event_id, |
|
|
|
event_id, |
|
|
|
elapsed.as_secs() / 60, |
|
|
|
elapsed.as_secs() / 60, |
|
|
|
elapsed.as_secs() % 60 |
|
|
|
elapsed.as_secs() % 60 |
|
|
|
@ -850,6 +850,8 @@ pub fn handle_incoming_pdu<'a>( |
|
|
|
pub_key_map: &'a RwLock<BTreeMap<String, BTreeMap<String, String>>>, |
|
|
|
pub_key_map: &'a RwLock<BTreeMap<String, BTreeMap<String, String>>>, |
|
|
|
) -> AsyncRecursiveType<'a, StdResult<Option<Vec<u8>>, String>> { |
|
|
|
) -> AsyncRecursiveType<'a, StdResult<Option<Vec<u8>>, String>> { |
|
|
|
Box::pin(async move { |
|
|
|
Box::pin(async move { |
|
|
|
|
|
|
|
let start_time = Instant::now(); |
|
|
|
|
|
|
|
|
|
|
|
// TODO: For RoomVersion6 we must check that Raw<..> is canonical do we anywhere?: https://matrix.org/docs/spec/rooms/v6#canonical-json
|
|
|
|
// TODO: For RoomVersion6 we must check that Raw<..> is canonical do we anywhere?: https://matrix.org/docs/spec/rooms/v6#canonical-json
|
|
|
|
match db.rooms.exists(&room_id) { |
|
|
|
match db.rooms.exists(&room_id) { |
|
|
|
Ok(true) => {} |
|
|
|
Ok(true) => {} |
|
|
|
@ -1014,12 +1016,18 @@ pub fn handle_incoming_pdu<'a>( |
|
|
|
// 8. if not timeline event: stop
|
|
|
|
// 8. if not timeline event: stop
|
|
|
|
if !is_timeline_event |
|
|
|
if !is_timeline_event |
|
|
|
|| incoming_pdu.origin_server_ts |
|
|
|
|| incoming_pdu.origin_server_ts |
|
|
|
< db.rooms |
|
|
|
< (utils::millis_since_unix_epoch() - 1000 * 60 * 20) |
|
|
|
.first_pdu_in_room(&room_id) |
|
|
|
.try_into() |
|
|
|
.map_err(|_| "Error loading first room event.".to_owned())? |
|
|
|
.expect("time is valid") |
|
|
|
.expect("Room exists") |
|
|
|
// Not older than 20 mins
|
|
|
|
.origin_server_ts |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
let elapsed = start_time.elapsed(); |
|
|
|
|
|
|
|
warn!( |
|
|
|
|
|
|
|
"Handling outlier event {} took {}m{}s", |
|
|
|
|
|
|
|
event_id, |
|
|
|
|
|
|
|
elapsed.as_secs() / 60, |
|
|
|
|
|
|
|
elapsed.as_secs() % 60 |
|
|
|
|
|
|
|
); |
|
|
|
return Ok(None); |
|
|
|
return Ok(None); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -1312,7 +1320,8 @@ pub fn handle_incoming_pdu<'a>( |
|
|
|
for state in fork_states { |
|
|
|
for state in fork_states { |
|
|
|
auth_chain_sets.push( |
|
|
|
auth_chain_sets.push( |
|
|
|
get_auth_chain(state.iter().map(|(_, id)| id.clone()).collect(), db) |
|
|
|
get_auth_chain(state.iter().map(|(_, id)| id.clone()).collect(), db) |
|
|
|
.map_err(|_| "Failed to load auth chain.".to_owned())?.collect(), |
|
|
|
.map_err(|_| "Failed to load auth chain.".to_owned())? |
|
|
|
|
|
|
|
.collect(), |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -1385,6 +1394,14 @@ pub fn handle_incoming_pdu<'a>( |
|
|
|
|
|
|
|
|
|
|
|
// Event has passed all auth/stateres checks
|
|
|
|
// Event has passed all auth/stateres checks
|
|
|
|
drop(state_lock); |
|
|
|
drop(state_lock); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let elapsed = start_time.elapsed(); |
|
|
|
|
|
|
|
warn!( |
|
|
|
|
|
|
|
"Handling timeline event {} took {}m{}s", |
|
|
|
|
|
|
|
event_id, |
|
|
|
|
|
|
|
elapsed.as_secs() / 60, |
|
|
|
|
|
|
|
elapsed.as_secs() % 60 |
|
|
|
|
|
|
|
); |
|
|
|
Ok(pdu_id) |
|
|
|
Ok(pdu_id) |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
@ -1757,7 +1774,10 @@ fn append_incoming_pdu( |
|
|
|
Ok(pdu_id) |
|
|
|
Ok(pdu_id) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fn get_auth_chain(starting_events: Vec<EventId>, db: &Database) -> Result<impl Iterator<Item = EventId> + '_> { |
|
|
|
fn get_auth_chain( |
|
|
|
|
|
|
|
starting_events: Vec<EventId>, |
|
|
|
|
|
|
|
db: &Database, |
|
|
|
|
|
|
|
) -> Result<impl Iterator<Item = EventId> + '_> { |
|
|
|
let mut full_auth_chain = HashSet::new(); |
|
|
|
let mut full_auth_chain = HashSet::new(); |
|
|
|
|
|
|
|
|
|
|
|
let starting_events = starting_events |
|
|
|
let starting_events = starting_events |
|
|
|
|