mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-08 06:33:09 -06:00
Sort and unique
This commit is contained in:
parent
1a39c20a35
commit
db89a7e813
|
|
@ -233,11 +233,16 @@ func (u *latestEventsUpdater) latestState() error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get a list of the current latest events. This may or may not
|
// Take the old set of extremities and the new set of extremities and
|
||||||
// include the new event from the input path, depending on whether
|
// mash them together into a list. This may or may not include the new event
|
||||||
// it is a forward extremity or not.
|
// from the input path, depending on whether it became a forward extremity
|
||||||
combinedExtremities := types.StateAtEventAndReferences(append(u.latest, u.oldLatest...))
|
// or not. We'll then run state resolution across all of them to determine
|
||||||
util.Unique(combinedExtremities)
|
// the new current state of the room. Including the old extremities here
|
||||||
|
// ensures that new forward extremities with bad state snapshots (from
|
||||||
|
// possible malicious actors) can't completely corrupt the room state
|
||||||
|
// away from what it was before.
|
||||||
|
combinedExtremities := types.StateAtEventAndReferences(append(u.oldLatest, u.latest...))
|
||||||
|
util.SortAndUnique(combinedExtremities)
|
||||||
latestStateAtEvents := make([]types.StateAtEvent, len(combinedExtremities))
|
latestStateAtEvents := make([]types.StateAtEvent, len(combinedExtremities))
|
||||||
for i := range combinedExtremities {
|
for i := range combinedExtremities {
|
||||||
latestStateAtEvents[i] = combinedExtremities[i].StateAtEvent
|
latestStateAtEvents[i] = combinedExtremities[i].StateAtEvent
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue