Improved solution to current_shortstatehash > next_batch. (59b62b1)

`current_shortstatehash` is now calculated from timeline which is already
upper-bound by the `next_batch` snapshot. Previously `current_shortstatehash`
was truly current and had to be disallowed from exceeding `next_batch` by
ignoring the room during sync until a future pass when these values finally
met that condition.

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk
2025-08-10 08:59:57 +00:00
parent 3e2f2fbffa
commit 3430d4ac86
5 changed files with 46 additions and 53 deletions

View File

@@ -222,11 +222,14 @@ pub async fn last_timeline_count(
&self,
sender_user: Option<&UserId>,
room_id: &RoomId,
upper_bound: Option<PduCount>,
) -> Result<PduCount> {
let upper_bound = upper_bound.unwrap_or_else(PduCount::max);
let pdus_rev = self.pdus_rev(sender_user, room_id, None);
pin_mut!(pdus_rev);
let last_count = pdus_rev
.ready_try_skip_while(|&(pducount, _)| Ok(pducount > upper_bound))
.try_next()
.await?
.map(at!(0))