Adjust forward elatest events updater

This commit is contained in:
Neil Alexander 2020-12-09 12:28:22 +00:00
parent f64c8822bc
commit 0c86d974b2
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944

View file

@ -290,11 +290,9 @@ func (u *latestEventsUpdater) calculateLatest(
// 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 {
return false, nil
}
}
// Include our new event in the extremities.
newLatest := []types.StateAtEventAndReference{newStateAndRef}
@ -306,14 +304,6 @@ 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)