mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-04 20:53:09 -06:00
Remove duplicates
This commit is contained in:
parent
d6d61c3707
commit
a1c5c1b997
|
|
@ -236,8 +236,10 @@ func (u *latestEventsUpdater) latestState() error {
|
|||
// Get a list of the current latest events. This may or may not
|
||||
// include the new event from the input path, depending on whether
|
||||
// it is a forward extremity or not.
|
||||
latestStateAtEvents := make([]types.StateAtEvent, len(u.latest))
|
||||
for i := range append(u.latest, u.oldLatest...) {
|
||||
combinedExtremities := types.StateAtEventAndReferences(append(u.latest, u.oldLatest...))
|
||||
util.Unique(combinedExtremities)
|
||||
latestStateAtEvents := make([]types.StateAtEvent, len(combinedExtremities))
|
||||
for i := range combinedExtremities {
|
||||
latestStateAtEvents[i] = u.latest[i].StateAtEvent
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ package types
|
|||
import (
|
||||
"encoding/json"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/matrix-org/gomatrixserverlib"
|
||||
"golang.org/x/crypto/blake2b"
|
||||
|
|
@ -166,6 +167,20 @@ type StateAtEventAndReference struct {
|
|||
gomatrixserverlib.EventReference
|
||||
}
|
||||
|
||||
type StateAtEventAndReferences []StateAtEventAndReference
|
||||
|
||||
func (s StateAtEventAndReferences) Less(a, b int) bool {
|
||||
return strings.Compare(s[a].EventID, s[b].EventID) < 0
|
||||
}
|
||||
|
||||
func (s StateAtEventAndReferences) Len() int {
|
||||
return len(s)
|
||||
}
|
||||
|
||||
func (s StateAtEventAndReferences) Swap(a, b int) {
|
||||
s[a], s[b] = s[b], s[a]
|
||||
}
|
||||
|
||||
// An Event is a gomatrixserverlib.Event with the numeric event ID attached.
|
||||
// It is when performing bulk event lookup in the database.
|
||||
type Event struct {
|
||||
|
|
|
|||
Loading…
Reference in a new issue