From a707266e50a770a2bdb272600e09671fe6ca8e41 Mon Sep 17 00:00:00 2001 From: David Robertson Date: Wed, 15 Jun 2022 12:32:58 +0100 Subject: [PATCH] Note a more efficient computation of the auth difference. (#1119) --- .../newsfragments/1119.clarification | 1 + content/rooms/fragments/v2-state-res.md | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) create mode 100644 changelogs/room_versions/newsfragments/1119.clarification diff --git a/changelogs/room_versions/newsfragments/1119.clarification b/changelogs/room_versions/newsfragments/1119.clarification new file mode 100644 index 00000000..1ce6591a --- /dev/null +++ b/changelogs/room_versions/newsfragments/1119.clarification @@ -0,0 +1 @@ +For room version 2 through 10: Note a more efficient way to compute the auth difference during state resolution. diff --git a/content/rooms/fragments/v2-state-res.md b/content/rooms/fragments/v2-state-res.md index 51331b44..cbfb6ca2 100644 --- a/content/rooms/fragments/v2-state-res.md +++ b/content/rooms/fragments/v2-state-res.md @@ -47,13 +47,20 @@ all of *their* auth events, and so on recursively, stretching back to the start of the room. Put differently, these are the events reachable by walking the graph induced by an event's `auth_events` links. +If *S* is a collection of +events, the *full auth chain of S* is the union of the auth chains of every +event *E* in *S*. + **Auth difference.** -The *auth difference* is calculated by first calculating the full auth -chain for each state *S**i*, that is the union of the auth -chains for each event in *S**i*, and then taking every event -that doesn't appear in every auth chain. If *C**i* is the -full auth chain of *S**i*, then the auth difference is - ∪ *C**i* −  ∩ *C**i*. +For each state *Si*, compute its full auth chain. +The *auth difference* is the set of events which belong to some, but not all, +of these full auth chains. In symbols: if *F*(*S*) is the full auth +chain of a collection of events *S*, the auth difference is + ∪*i* *F*(*Si*) - ∩*i* *F*(*Si*). + +This can be computed more efficiently as + *F*(*C*) - ∩*i* *F*(*S**i* - *C*) , +where *C* is the conflicted state set. **Full conflicted set.** The *full conflicted set* is the union of the conflicted state set and