mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-26 08:13:09 -06:00
Adjust forward elatest events updater
This commit is contained in:
parent
f64c8822bc
commit
0c86d974b2
|
|
@ -290,11 +290,9 @@ func (u *latestEventsUpdater) calculateLatest(
|
||||||
|
|
||||||
// If the "new" event is already a forward extremity then stop, as
|
// If the "new" event is already a forward extremity then stop, as
|
||||||
// nothing changes.
|
// nothing changes.
|
||||||
for _, event := range events {
|
if _, ok := existingRefs[newEvent.EventID()]; ok {
|
||||||
if event.EventID() == newEvent.EventID() {
|
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Include our new event in the extremities.
|
// Include our new event in the extremities.
|
||||||
newLatest := []types.StateAtEventAndReference{newStateAndRef}
|
newLatest := []types.StateAtEventAndReference{newStateAndRef}
|
||||||
|
|
@ -306,14 +304,6 @@ func (u *latestEventsUpdater) calculateLatest(
|
||||||
delete(existingRefs, prevEventID)
|
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.
|
// Then re-add any old extremities that are still valid after all.
|
||||||
for _, old := range existingRefs {
|
for _, old := range existingRefs {
|
||||||
newLatest = append(newLatest, *old)
|
newLatest = append(newLatest, *old)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue