mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-08-02 22:22:46 +00:00
Initial work on simplified state storage
This commit is contained in:
parent
e08942fb00
commit
a799847070
21 changed files with 540 additions and 1297 deletions
|
@ -74,6 +74,24 @@ func (a StateEntry) LessThan(b StateEntry) bool {
|
|||
return a.EventNID < b.EventNID
|
||||
}
|
||||
|
||||
// Deduplicate takes a set of event NIDs and ensures that there are no
|
||||
// duplicates. If there are then we dedupe them.
|
||||
func DeduplicateEventNIDs(a []EventNID) []EventNID {
|
||||
if len(a) < 2 {
|
||||
return a
|
||||
}
|
||||
sort.SliceStable(a, func(i, j int) bool {
|
||||
return a[i] < a[j]
|
||||
})
|
||||
for i := 0; i < len(a)-1; i++ {
|
||||
if a[i] == a[i+1] {
|
||||
a = append(a[:i], a[i+1:]...)
|
||||
i--
|
||||
}
|
||||
}
|
||||
return a
|
||||
}
|
||||
|
||||
// Deduplicate takes a set of state entries and ensures that there are no
|
||||
// duplicate (event type, state key) tuples. If there are then we dedupe
|
||||
// them, making sure that the latest/highest NIDs are always chosen.
|
||||
|
@ -151,18 +169,6 @@ const (
|
|||
EmptyStateKeyNID = 1
|
||||
)
|
||||
|
||||
// StateBlockNIDList is used to return the result of bulk StateBlockNID lookups from the database.
|
||||
type StateBlockNIDList struct {
|
||||
StateSnapshotNID StateSnapshotNID
|
||||
StateBlockNIDs []StateBlockNID
|
||||
}
|
||||
|
||||
// StateEntryList is used to return the result of bulk state entry lookups from the database.
|
||||
type StateEntryList struct {
|
||||
StateBlockNID StateBlockNID
|
||||
StateEntries []StateEntry
|
||||
}
|
||||
|
||||
// A MissingEventError is an error that happened because the roomserver was
|
||||
// missing requested events from its database.
|
||||
type MissingEventError string
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue