mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-07-31 13:22:46 +00:00
Resolve over old and new extremities (#2457)
* Feed existing state into state res when calculating state from new extremities * Remove duplicates * Fix bug * Sort and unique * Update to matrix-org/gomatrixserverlib#308 * Trim the slice properly * Update gomatrixserverlib again * Update to matrix-org/gomatrixserverlib#308
This commit is contained in:
parent
cafc2d2c10
commit
be9be2553f
4 changed files with 31 additions and 9 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue