|
|
|
@ -768,9 +768,11 @@ pub async fn send_transaction_message_route<'a>( |
|
|
|
// find the leaves otherwise we would do this sooner
|
|
|
|
// find the leaves otherwise we would do this sooner
|
|
|
|
append_incoming_pdu(&db, &pdu, &extremities, &state_at_event)?; |
|
|
|
append_incoming_pdu(&db, &pdu, &extremities, &state_at_event)?; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// This will create the state after any state snapshot it builds
|
|
|
|
|
|
|
|
// So current_state will have the incoming event inserted to it
|
|
|
|
let mut fork_states = match build_forward_extremity_snapshots( |
|
|
|
let mut fork_states = match build_forward_extremity_snapshots( |
|
|
|
&db, |
|
|
|
&db, |
|
|
|
pdu.room_id(), |
|
|
|
pdu.clone(), |
|
|
|
server_name, |
|
|
|
server_name, |
|
|
|
current_state, |
|
|
|
current_state, |
|
|
|
&extremities, |
|
|
|
&extremities, |
|
|
|
@ -1195,14 +1197,14 @@ pub(crate) async fn calculate_forward_extremities( |
|
|
|
/// and the sending server).
|
|
|
|
/// and the sending server).
|
|
|
|
pub(crate) async fn build_forward_extremity_snapshots( |
|
|
|
pub(crate) async fn build_forward_extremity_snapshots( |
|
|
|
db: &Database, |
|
|
|
db: &Database, |
|
|
|
room_id: &RoomId, |
|
|
|
pdu: Arc<PduEvent>, |
|
|
|
origin: &ServerName, |
|
|
|
origin: &ServerName, |
|
|
|
current_state: StateMap<Arc<PduEvent>>, |
|
|
|
mut current_state: StateMap<Arc<PduEvent>>, |
|
|
|
current_leaves: &[EventId], |
|
|
|
current_leaves: &[EventId], |
|
|
|
pub_key_map: &PublicKeyMap, |
|
|
|
pub_key_map: &PublicKeyMap, |
|
|
|
auth_cache: &mut EventMap<Arc<PduEvent>>, |
|
|
|
auth_cache: &mut EventMap<Arc<PduEvent>>, |
|
|
|
) -> Result<BTreeSet<StateMap<Arc<PduEvent>>>> { |
|
|
|
) -> Result<BTreeSet<StateMap<Arc<PduEvent>>>> { |
|
|
|
let current_hash = db.rooms.current_state_hash(room_id)?; |
|
|
|
let current_hash = db.rooms.current_state_hash(pdu.room_id())?; |
|
|
|
|
|
|
|
|
|
|
|
let mut includes_current_state = false; |
|
|
|
let mut includes_current_state = false; |
|
|
|
let mut fork_states = BTreeSet::new(); |
|
|
|
let mut fork_states = BTreeSet::new(); |
|
|
|
@ -1219,7 +1221,7 @@ pub(crate) async fn build_forward_extremity_snapshots( |
|
|
|
|
|
|
|
|
|
|
|
let mut state_before = db |
|
|
|
let mut state_before = db |
|
|
|
.rooms |
|
|
|
.rooms |
|
|
|
.state_full(room_id, &state_hash)? |
|
|
|
.state_full(pdu.room_id(), &state_hash)? |
|
|
|
.into_iter() |
|
|
|
.into_iter() |
|
|
|
.map(|(k, v)| ((k.0, Some(k.1)), Arc::new(v))) |
|
|
|
.map(|(k, v)| ((k.0, Some(k.1)), Arc::new(v))) |
|
|
|
.collect::<StateMap<_>>(); |
|
|
|
.collect::<StateMap<_>>(); |
|
|
|
@ -1238,7 +1240,7 @@ pub(crate) async fn build_forward_extremity_snapshots( |
|
|
|
&db.globals, |
|
|
|
&db.globals, |
|
|
|
origin, |
|
|
|
origin, |
|
|
|
get_room_state_ids::v1::Request { |
|
|
|
get_room_state_ids::v1::Request { |
|
|
|
room_id, |
|
|
|
room_id: pdu.room_id(), |
|
|
|
event_id: id, |
|
|
|
event_id: id, |
|
|
|
}, |
|
|
|
}, |
|
|
|
) |
|
|
|
) |
|
|
|
@ -1269,6 +1271,9 @@ pub(crate) async fn build_forward_extremity_snapshots( |
|
|
|
|
|
|
|
|
|
|
|
// This guarantees that our current room state is included
|
|
|
|
// This guarantees that our current room state is included
|
|
|
|
if !includes_current_state && current_hash.is_some() { |
|
|
|
if !includes_current_state && current_hash.is_some() { |
|
|
|
|
|
|
|
error!("Did not include current state"); |
|
|
|
|
|
|
|
current_state.insert((pdu.kind(), pdu.state_key()), pdu); |
|
|
|
|
|
|
|
|
|
|
|
fork_states.insert(current_state); |
|
|
|
fork_states.insert(current_state); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|