From 0f15c6bf903e623b5bc491e994e0e3f878bac37c Mon Sep 17 00:00:00 2001 From: Till Faelligen <2353100+S7evinK@users.noreply.github.com> Date: Sat, 20 Jan 2024 20:34:04 +0100 Subject: [PATCH] Make 100 a const --- roomserver/api/perform.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/roomserver/api/perform.go b/roomserver/api/perform.go index bdefbef83..9e00da2c0 100644 --- a/roomserver/api/perform.go +++ b/roomserver/api/perform.go @@ -90,6 +90,10 @@ type PerformBackfillRequest struct { VirtualHost spec.ServerName `json:"virtual_host"` } +// limitPrevEventIDs is the maximum of eventIDs we +// return when calling PrevEventIDs. +const limitPrevEventIDs = 100 + // PrevEventIDs returns the prev_event IDs of either 100 backwards extremities or // len(r.BackwardsExtremities). Limited to 100, due to Synapse/Dendrite stopping after reaching // this limit. (which sounds sane) @@ -98,8 +102,8 @@ func (r *PerformBackfillRequest) PrevEventIDs() []string { // Create a unique eventID map of either 100 or len(r.BackwardsExtremities). // 100 since Synapse/Dendrite stops after reaching 100 events. - if len(r.BackwardsExtremities) > 100 { - uniqueIDs = make(map[string]struct{}, 100) + if len(r.BackwardsExtremities) > limitPrevEventIDs { + uniqueIDs = make(map[string]struct{}, limitPrevEventIDs) } else { uniqueIDs = make(map[string]struct{}, len(r.BackwardsExtremities)) } @@ -109,7 +113,7 @@ outerLoop: for _, evID := range pes { uniqueIDs[evID] = struct{}{} // We found enough unique eventIDs. - if len(uniqueIDs) >= 100 { + if len(uniqueIDs) >= limitPrevEventIDs { break outerLoop } }