Broadcast send_join concurrent to other operations; pre-gather state concurrently.

Broadcast send_knock concurrently.

Concurrent access check for fed event.

Concurrent gather for state responses.

Populate room_version for format_pdu to elide repeated queries.

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk
2025-09-25 01:05:12 +00:00
parent b9c790326a
commit 85b3de055d
8 changed files with 159 additions and 95 deletions

View File

@@ -1,7 +1,7 @@
use std::{borrow::Borrow, iter::once};
use axum::extract::State;
use futures::{StreamExt, TryStreamExt};
use futures::{FutureExt, StreamExt, TryStreamExt, future::try_join};
use ruma::{OwnedEventId, api::federation::event::get_room_state_ids};
use tuwunel_core::{Result, at, err};
@@ -31,18 +31,19 @@ pub(crate) async fn get_room_state_ids_route(
.await
.map_err(|_| err!(Request(NotFound("Pdu state not found."))))?;
let pdu_ids: Vec<OwnedEventId> = services
.state_accessor
.state_full_ids(shortstatehash)
.map(at!(1))
.collect()
.await;
let auth_chain_ids = services
.auth_chain
.event_ids_iter(&body.room_id, once(body.event_id.borrow()))
.try_collect()
.await?;
.try_collect();
let pdu_ids = services
.state_accessor
.state_full_ids(shortstatehash)
.map(at!(1))
.collect::<Vec<OwnedEventId>>()
.map(Ok);
let (auth_chain_ids, pdu_ids) = try_join(auth_chain_ids, pdu_ids).await?;
Ok(get_room_state_ids::v1::Response { auth_chain_ids, pdu_ids })
}