From 2ef90a65d93ebc78f131768faf069765d363ec19 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Wed, 9 Dec 2020 12:38:08 +0000 Subject: [PATCH] Re-add existingPrevs loop --- roomserver/internal/input/input_latest_events.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/roomserver/internal/input/input_latest_events.go b/roomserver/internal/input/input_latest_events.go index b88dc1764..9554bf330 100644 --- a/roomserver/internal/input/input_latest_events.go +++ b/roomserver/internal/input/input_latest_events.go @@ -306,6 +306,14 @@ func (u *latestEventsUpdater) calculateLatest( delete(existingRefs, prevEventID) } + // Ensure that we don't add any candidate forward extremities from + // the old set that are, themselves, referenced by the old set of + // forward extremities. This shouldn't happen but guards against + // the possibility anyway. + for prevEventID := range existingPrevs { + delete(existingRefs, prevEventID) + } + // Then re-add any old extremities that are still valid after all. for _, old := range existingRefs { newLatest = append(newLatest, *old)