fix: Lower floor for min depth

This commit is contained in:
timedout committed 2026-06-20 17:07:59 +01:00
1 parent b9dca84acf
commit f80e1e89a5
1 file changed
+15 -6
+15 -6
View File
@@ -2,11 +2,11 @@ use std::collections::HashMap;
use conduwuit::{ use conduwuit::{
Event, PduEvent, debug, debug_info, Event, PduEvent, debug, debug_info,
utils::{BoolExt, IterStream, stream::BroadbandExt}, utils::{BoolExt, IterStream, math::try_into, stream::BroadbandExt},
warn, warn,
}; };
use futures::StreamExt; use futures::StreamExt;
use ruma::{RoomId, ServerName}; use ruma::{RoomId, ServerName, UInt};
use crate::rooms::event_handler::build_local_dag; use crate::rooms::event_handler::build_local_dag;
@@ -45,19 +45,28 @@ impl super::Service {
.collect::<Vec<_>>() .collect::<Vec<_>>()
.await; .await;
let backfilled = self let gapfilled = self
.get_missing_events( .get_missing_events(
room_id, room_id,
incoming_pdu, incoming_pdu,
tail, tail,
origin, origin,
self.services.metadata.get_mindepth(room_id).await, self.services
.metadata
.get_mindepth(room_id)
.await
.saturating_sub(
u8::try_from(incoming_pdu.prev_events.len())
.unwrap()
.saturating_mul(2)
.into(),
),
) )
.await?; .await?;
debug_info!("Fetched {} missing events", backfilled.len()); debug_info!("Fetched {} missing events", gapfilled.len());
// Persist all fetched events // Persist all fetched events
let mapped = backfilled let mapped = gapfilled
.iter() .iter()
.map(|(eid, evt)| { .map(|(eid, evt)| {
let mut obj = evt.to_canonical_object(); let mut obj = evt.to_canonical_object();