state-res: Revert calculating the auth chain in ruma

In a previous commit I moved the auth chain calculation code to ruma
because I thought I could optimize it by only taking auth chains from
conflicted events instead of all events. It turned out that was wrong
and now I removed that algorithm again (the full auth chains are now
passed in as an argument to state_res::resolve again).
This commit is contained in:
Timo Kösters
2021-07-16 09:33:49 +02:00
committed by Jonas Platte
parent 63411165da
commit d970501c85
6 changed files with 70 additions and 56 deletions

View File

@@ -66,6 +66,14 @@ fn resolution_shallow_auth_chain(c: &mut Criterion) {
&room_id(),
&RoomVersionId::Version6,
&state_sets,
state_sets
.iter()
.map(|map| {
store
.auth_event_ids(&room_id(), &map.values().cloned().collect::<Vec<_>>())
.unwrap()
})
.collect(),
|id| ev_map.get(id).map(Arc::clone),
) {
Ok(state) => state,
@@ -81,7 +89,7 @@ fn resolve_deeper_event_set(c: &mut Criterion) {
let ban = BAN_STATE_SET();
inner.extend(ban);
let _store = TestStore(inner.clone());
let store = TestStore(inner.clone());
let state_set_a = [
inner.get(&event_id("CREATE")).unwrap(),
@@ -115,6 +123,14 @@ fn resolve_deeper_event_set(c: &mut Criterion) {
&room_id(),
&RoomVersionId::Version6,
&state_sets,
state_sets
.iter()
.map(|map| {
store
.auth_event_ids(&room_id(), &map.values().cloned().collect::<Vec<_>>())
.unwrap()
})
.collect(),
|id| inner.get(id).map(Arc::clone),
) {
Ok(state) => state,
@@ -159,8 +175,8 @@ impl<E: Event> TestStore<E> {
}
/// Returns a Vec of the related auth events to the given `event`.
pub fn auth_event_ids(&self, room_id: &RoomId, event_ids: &[EventId]) -> Result<Vec<EventId>> {
let mut result = vec![];
pub fn auth_event_ids(&self, room_id: &RoomId, event_ids: &[EventId]) -> Result<BTreeSet<EventId>> {
let mut result = BTreeSet::new();
let mut stack = event_ids.to_vec();
// DFS for auth event chain
@@ -170,7 +186,7 @@ impl<E: Event> TestStore<E> {
continue;
}
result.push(ev_id.clone());
result.insert(ev_id.clone());
let event = self.get_event(room_id, &ev_id)?;