Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Matrix
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container Registry
Model registry
Operate
Environments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
Matrix
Commits
dc41fbf0
Commit
dc41fbf0
authored
5 years ago
by
Richard van der Hoff
Browse files
Options
Downloads
Patches
Plain Diff
Remove unused get_prev_events_and_hashes_for_room
parent
38e0829a
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
synapse/storage/data_stores/main/event_federation.py
+0
-30
0 additions, 30 deletions
synapse/storage/data_stores/main/event_federation.py
tests/storage/test_event_federation.py
+6
-13
6 additions, 13 deletions
tests/storage/test_event_federation.py
with
6 additions
and
43 deletions
synapse/storage/data_stores/main/event_federation.py
+
0
−
30
View file @
dc41fbf0
...
...
@@ -14,7 +14,6 @@
# limitations under the License.
import
itertools
import
logging
import
random
from
six.moves
import
range
from
six.moves.queue
import
Empty
,
PriorityQueue
...
...
@@ -148,35 +147,6 @@ class EventFederationWorkerStore(EventsWorkerStore, SignatureWorkerStore, SQLBas
retcol
=
"
event_id
"
,
)
@defer.inlineCallbacks
def
get_prev_events_and_hashes_for_room
(
self
,
room_id
):
"""
Gets a subset of the current forward extremities in the given room,
along with their depths and hashes.
Limits the result to 10 extremities, so that we can avoid creating
events which refer to hundreds of prev_events.
Args:
room_id (str): room_id
Returns:
Deferred[list[(str, dict[str, str], int)]]
for each event, a tuple of (event_id, hashes, depth)
where *hashes* is a map from algorithm to hash.
"""
res
=
yield
self
.
get_latest_event_ids_and_hashes_in_room
(
room_id
)
if
len
(
res
)
>
10
:
# Sort by reverse depth, so we point to the most recent.
res
.
sort
(
key
=
lambda
a
:
-
a
[
2
])
# we use half of the limit for the actual most recent events, and
# the other half to randomly point to some of the older events, to
# make sure that we don't completely ignore the older events.
res
=
res
[
0
:
5
]
+
random
.
sample
(
res
[
5
:],
5
)
return
res
def
get_prev_events_for_room
(
self
,
room_id
:
str
):
"""
Gets a subset of the current forward extremities in the given room.
...
...
This diff is collapsed.
Click to expand it.
tests/storage/test_event_federation.py
+
6
−
13
View file @
dc41fbf0
...
...
@@ -26,7 +26,7 @@ class EventFederationWorkerStoreTestCase(tests.unittest.TestCase):
self
.
store
=
hs
.
get_datastore
()
@defer.inlineCallbacks
def
test_get_prev_events_
and_hashes_
for_room
(
self
):
def
test_get_prev_events_for_room
(
self
):
room_id
=
"
@ROOM:local
"
# add a bunch of events and hashes to act as forward extremities
...
...
@@ -60,21 +60,14 @@ class EventFederationWorkerStoreTestCase(tests.unittest.TestCase):
(
event_id
,
bytearray
(
b
"
ffff
"
)),
)
for
i
in
range
(
0
,
11
):
for
i
in
range
(
0
,
20
):
yield
self
.
store
.
db
.
runInteraction
(
"
insert
"
,
insert_event
,
i
)
# this should get the last
five and five others
r
=
yield
self
.
store
.
get_prev_events_
and_hashes_
for_room
(
room_id
)
# this should get the last
ten
r
=
yield
self
.
store
.
get_prev_events_for_room
(
room_id
)
self
.
assertEqual
(
10
,
len
(
r
))
for
i
in
range
(
0
,
5
):
el
=
r
[
i
]
depth
=
el
[
2
]
self
.
assertEqual
(
10
-
i
,
depth
)
for
i
in
range
(
5
,
5
):
el
=
r
[
i
]
depth
=
el
[
2
]
self
.
assertLessEqual
(
5
,
depth
)
for
i
in
range
(
0
,
10
):
self
.
assertEqual
(
"
$event_%i:local
"
%
(
19
-
i
),
r
[
i
])
@defer.inlineCallbacks
def
test_get_rooms_with_many_extremities
(
self
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment