Sort the events and skip if eventID is equal beforeID
This commit is contained in:
parent
26375dd56a
commit
638300efd0
|
@ -12,6 +12,7 @@ import (
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"os"
|
"os"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"sort"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/matrix-org/gomatrixserverlib"
|
"github.com/matrix-org/gomatrixserverlib"
|
||||||
|
@ -112,6 +113,7 @@ func main() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
var createSeen bool
|
var createSeen bool
|
||||||
|
sort.Sort(headeredEvents(evs))
|
||||||
for _, x := range evs {
|
for _, x := range evs {
|
||||||
if _, ok := seenEvents[x.EventID()]; ok {
|
if _, ok := seenEvents[x.EventID()]; ok {
|
||||||
continue
|
continue
|
||||||
|
@ -147,6 +149,9 @@ func main() {
|
||||||
if _, ok := seenEvents[x.EventID()]; ok {
|
if _, ok := seenEvents[x.EventID()]; ok {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
if x.EventID() == beforeEvID {
|
||||||
|
continue
|
||||||
|
}
|
||||||
eventID = x.EventID()
|
eventID = x.EventID()
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
@ -162,6 +167,20 @@ func main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type headeredEvents []*gomatrixserverlib.HeaderedEvent
|
||||||
|
|
||||||
|
func (h headeredEvents) Len() int {
|
||||||
|
return len(h)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h headeredEvents) Less(i, j int) bool {
|
||||||
|
return h[i].Depth() < h[j].Depth()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h headeredEvents) Swap(i, j int) {
|
||||||
|
h[i], h[j] = h[j], h[i]
|
||||||
|
}
|
||||||
|
|
||||||
type backfiller struct {
|
type backfiller struct {
|
||||||
FedClient *gomatrixserverlib.FederationClient
|
FedClient *gomatrixserverlib.FederationClient
|
||||||
servers map[gomatrixserverlib.ServerName]struct{}
|
servers map[gomatrixserverlib.ServerName]struct{}
|
||||||
|
|
Loading…
Reference in a new issue