Adjust latest events updater (#1623)

* Adjust forward elatest events updater

* Populate newLatest in all cases

* Re-add existingPrevs loop
This commit is contained in:
Neil Alexander 2020-12-09 13:34:37 +00:00 committed by GitHub
parent f64c8822bc
commit d9b3035342
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -285,16 +285,16 @@ 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() {
if _, ok := existingRefs[newEvent.EventID()]; ok {
u.latest = oldLatest
return false, nil
}
}
// Include our new event in the extremities.
newLatest := []types.StateAtEventAndReference{newStateAndRef}