aboutsummaryrefslogtreecommitdiff
path: root/syncapi/routing
diff options
context:
space:
mode:
authorKegsay <kegan@matrix.org>2020-05-14 17:30:16 +0100
committerGitHub <noreply@github.com>2020-05-14 17:30:16 +0100
commit7ca230e931faceb0b8a9e60314258d6cd59f33d4 (patch)
treee1a6ba92d289e322111a39d230ea7accc7e61c85 /syncapi/routing
parent3cb04e80042104d14ccfa162b3e40a5b08819eac (diff)
Cleanup syncapi topology logic (#1035)
* Cleanup syncapi topology logic * Variable renaming * comments
Diffstat (limited to 'syncapi/routing')
-rw-r--r--syncapi/routing/messages.go16
1 files changed, 4 insertions, 12 deletions
diff --git a/syncapi/routing/messages.go b/syncapi/routing/messages.go
index 72c306d4..67de6df7 100644
--- a/syncapi/routing/messages.go
+++ b/syncapi/routing/messages.go
@@ -245,24 +245,20 @@ func (r *messagesReq) retrieveEvents() (
// change the way topological positions are defined (as depth isn't the most
// reliable way to define it), it would be easier and less troublesome to
// only have to change it in one place, i.e. the database.
- startPos, startStreamPos, err := r.db.EventPositionInTopology(
+ start, err = r.db.EventPositionInTopology(
r.ctx, events[0].EventID(),
)
if err != nil {
err = fmt.Errorf("EventPositionInTopology: for start event %s: %w", events[0].EventID(), err)
return
}
- endPos, endStreamPos, err := r.db.EventPositionInTopology(
+ end, err = r.db.EventPositionInTopology(
r.ctx, events[len(events)-1].EventID(),
)
if err != nil {
err = fmt.Errorf("EventPositionInTopology: for end event %s: %w", events[len(events)-1].EventID(), err)
return
}
- // Generate pagination tokens to send to the client using the positions
- // retrieved previously.
- start = types.NewTopologyToken(startPos, startStreamPos)
- end = types.NewTopologyToken(endPos, endStreamPos)
if r.backwardOrdering {
// A stream/topological position is a cursor located between two events.
@@ -431,14 +427,10 @@ func setToDefault(
) (to types.TopologyToken, err error) {
if backwardOrdering {
// go 1 earlier than the first event so we correctly fetch the earliest event
+ // this is because Database.GetEventsInTopologicalRange is exclusive of the lower-bound.
to = types.NewTopologyToken(0, 0)
} else {
- var depth, stream types.StreamPosition
- depth, stream, err = db.MaxTopologicalPosition(ctx, roomID)
- if err != nil {
- return
- }
- to = types.NewTopologyToken(depth, stream)
+ to, err = db.MaxTopologicalPosition(ctx, roomID)
}
return