style: Simplify build_local_dag return

This commit is contained in:
timedout
2026-04-27 23:00:29 +01:00
committed by Ellis Git
parent fe7cfd96e7
commit 8575f191a0
2 changed files with 9 additions and 6 deletions
+1
View File
@@ -0,0 +1 @@
Fixed a bug that caused the server to drop events during processing if several events for the same room were sent in a singular transaction. Contributed by @nex.
+8 -6
View File
@@ -309,7 +309,8 @@ async fn build_local_dag(
id_origin_ts.insert(event_id.clone(), origin_server_ts);
}
let sorted = lexicographical_topological_sort(&dag, &async |node_id| {
debug!(count=dag.len(), "Sorting incoming events with partial graph");
lexicographical_topological_sort(&dag, &async |node_id| {
// Note: we don't bother fetching power levels because that would massively slow
// this function down. This is a best-effort attempt to order events correctly
// for processing, however ultimately that should be the sender's job.
@@ -325,11 +326,12 @@ async fn build_local_dag(
Ok((int!(0), MilliSecondsSinceUnixEpoch(ts)))
})
.await
.map_err(|e| err!("failed to resolve local graph: {e}"));
if let Ok(ref s) = sorted {
assert_eq!(s.len(), pdu_map.len(), "Sorted graph was not the same size as the input graph");
};
sorted
.inspect(|sorted| assert_eq!(
sorted.len(),
pdu_map.len(),
"Sorted graph was not the same size as the input graph"
))
.map_err(|e| err!("failed to resolve local graph: {e}"))
}
async fn handle_room(