From 30f6dc22938ead7dbe49b3c2e9a7107e2333d3d7 Mon Sep 17 00:00:00 2001 From: David Robertson Date: Mon, 13 Jun 2022 15:59:34 +0100 Subject: [PATCH] Note a more efficient computation of the auth difference. --- content/rooms/fragments/v2-state-res.md | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/content/rooms/fragments/v2-state-res.md b/content/rooms/fragments/v2-state-res.md index e666d7f8..442e400f 100644 --- a/content/rooms/fragments/v2-state-res.md +++ b/content/rooms/fragments/v2-state-res.md @@ -45,15 +45,19 @@ whereas the conflicted state set may associate multiple events to the same key. The *auth chain* of an event *E* is the set containing all of *E*'s auth events, 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. +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*. +chain for each state *S**i*, and then discarding the events +belonging to each full auth chain. In symbols: if *C*(*S*) is the full auth +chain of a collection of events *S*, the auth difference is + ∪*i* *C*(*Si*) - ∩*i* *C*(*Si*). +This can be [computed more efficiently](https://github.com/matrix-org/matrix-spec/issues/1118) as + *C*(*F*) - ∩*i* *C*(*Si* - *F*) , +where *F* is the full conflicted set. **Full conflicted set.** The *full conflicted set* is the union of the conflicted state set and