revert changes to input_latest_events.go

This commit is contained in:
Tak Wai Wong 2022-06-14 15:02:19 -07:00
parent aa8ed3040e
commit e10f54d7f4

View file

@ -245,19 +245,12 @@ func (u *latestEventsUpdater) latestState() error {
} }
} }
// Take the old set of extremities and the new set of extremities and // Get a list of the current latest events. This may or may not
// mash them together into a list. This may or may not include the new event // include the new event from the input path, depending on whether
// from the input path, depending on whether it became a forward extremity // it is a forward extremity or not.
// or not. We'll then run state resolution across all of them to determine latestStateAtEvents := make([]types.StateAtEvent, len(u.latest))
// the new current state of the room. Including the old extremities here for i := range u.latest {
// ensures that new forward extremities with bad state snapshots (from latestStateAtEvents[i] = u.latest[i].StateAtEvent
// possible malicious actors) can't completely corrupt the room state
// away from what it was before.
combinedExtremities := types.StateAtEventAndReferences(append(u.oldLatest, u.latest...))
combinedExtremities = combinedExtremities[:util.SortAndUnique(combinedExtremities)]
latestStateAtEvents := make([]types.StateAtEvent, len(combinedExtremities))
for i := range combinedExtremities {
latestStateAtEvents[i] = combinedExtremities[i].StateAtEvent
} }
// Takes the NIDs of the latest events and creates a state snapshot // Takes the NIDs of the latest events and creates a state snapshot