mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-08-01 22:02:46 +00:00
Implement /get_missing_events (#1022)
* WIP get_missing_events work
* More WIP get_missing_events work
* First working /get_missing_events implementation
Flakey currently due to racing between /sync and /send
* Final tweaks
* Remove log lines
* Linting
* go mod tidy
* Clamp min depth to 0
* sort events by depth because sytest makes me sad
Specifically I think it's
4172585c25/lib/SyTest/Federation/Client.pm (L265)
to blame here.
This commit is contained in:
parent
32624697fd
commit
ce5dfbebf9
6 changed files with 675 additions and 198 deletions
|
@ -17,6 +17,7 @@ package routing
|
|||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"sort"
|
||||
"time"
|
||||
|
||||
"github.com/matrix-org/dendrite/clientapi/jsonerror"
|
||||
|
@ -275,6 +276,12 @@ func SendJoin(
|
|||
}
|
||||
}
|
||||
|
||||
// sort events deterministically by depth (lower is earlier)
|
||||
// We also do this because sytest's basic federation server isn't good at using the correct
|
||||
// state if these lists are randomised, resulting in flakey tests. :(
|
||||
sort.Sort(eventsByDepth(stateAndAuthChainResponse.StateEvents))
|
||||
sort.Sort(eventsByDepth(stateAndAuthChainResponse.AuthChainEvents))
|
||||
|
||||
// https://matrix.org/docs/spec/server_server/latest#put-matrix-federation-v1-send-join-roomid-eventid
|
||||
return util.JSONResponse{
|
||||
Code: http.StatusOK,
|
||||
|
@ -285,3 +292,15 @@ func SendJoin(
|
|||
},
|
||||
}
|
||||
}
|
||||
|
||||
type eventsByDepth []gomatrixserverlib.HeaderedEvent
|
||||
|
||||
func (e eventsByDepth) Len() int {
|
||||
return len(e)
|
||||
}
|
||||
func (e eventsByDepth) Swap(i, j int) {
|
||||
e[i], e[j] = e[j], e[i]
|
||||
}
|
||||
func (e eventsByDepth) Less(i, j int) bool {
|
||||
return e[i].Depth() < e[j].Depth()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue