From d9b3035342fe3b432bfbdf46d9f5a411d9cd9d39 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Wed, 9 Dec 2020 13:34:37 +0000 Subject: [PATCH] Adjust latest events updater (#1623) * Adjust forward elatest events updater * Populate newLatest in all cases * Re-add existingPrevs loop --- roomserver/internal/input/input_latest_events.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/roomserver/internal/input/input_latest_events.go b/roomserver/internal/input/input_latest_events.go index 3608ef4b0..9554bf330 100644 --- a/roomserver/internal/input/input_latest_events.go +++ b/roomserver/internal/input/input_latest_events.go @@ -285,15 +285,15 @@ func (u *latestEventsUpdater) calculateLatest( // then do nothing - it's not a candidate to be a new extremity if // it has been referenced. if _, ok := existingPrevs[newEvent.EventID()]; ok { + u.latest = oldLatest return false, nil } // If the "new" event is already a forward extremity then stop, as // nothing changes. - for _, event := range events { - if event.EventID() == newEvent.EventID() { - return false, nil - } + if _, ok := existingRefs[newEvent.EventID()]; ok { + u.latest = oldLatest + return false, nil } // Include our new event in the extremities.