fix: state bug

next
Timo Kösters 2021-07-20 23:36:03 +02:00
parent 80533bfab2
commit f121978897
No known key found for this signature in database
GPG Key ID: 24DA7517711A2BA4
2 changed files with 7 additions and 13 deletions

View File

@ -165,9 +165,8 @@ impl Sending {
let new_events = guard.sending.servernamepduids let new_events = guard.sending.servernamepduids
.scan_prefix(prefix.clone()) .scan_prefix(prefix.clone())
.filter_map(|(k, _)| { .filter_map(|(k, _)| {
Self::parse_servercurrentevent(&k).ok() Self::parse_servercurrentevent(&k).ok().map(|ev| (ev, k))
}) })
.map(|(_, event)| event)
.take(30) .take(30)
.collect::<Vec<_>>(); .collect::<Vec<_>>();
@ -175,16 +174,9 @@ impl Sending {
if !new_events.is_empty() { if !new_events.is_empty() {
// Insert pdus we found // Insert pdus we found
for event in &new_events { for (_, key) in &new_events {
let mut current_key = prefix.clone(); guard.sending.servercurrentevents.insert(&key, &[]).unwrap();
match event { guard.sending.servernamepduids.remove(&key).unwrap();
SendingEventType::Pdu(b) |
SendingEventType::Edu(b) => {
current_key.extend_from_slice(&b);
guard.sending.servercurrentevents.insert(&current_key, &[]).unwrap();
guard.sending.servernamepduids.remove(&current_key).unwrap();
}
}
} }
drop(guard); drop(guard);
@ -192,7 +184,7 @@ impl Sending {
futures.push( futures.push(
Self::handle_events( Self::handle_events(
outgoing_kind.clone(), outgoing_kind.clone(),
new_events, new_events.into_iter().map(|(event, _)| event.1).collect(),
Arc::clone(&db), Arc::clone(&db),
) )
); );

View File

@ -1058,6 +1058,8 @@ pub fn handle_incoming_pdu<'a>(
if let Some(state_key) = &prev_pdu.state_key { if let Some(state_key) = &prev_pdu.state_key {
state.insert((prev_pdu.kind.clone(), state_key.clone()), prev_pdu); state.insert((prev_pdu.kind.clone(), state_key.clone()), prev_pdu);
} }
state_at_incoming_event = Some(state);
} }
// TODO: set incoming_auth_events? // TODO: set incoming_auth_events?
} }