Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit 9c75e93

Browse files
committed
remove unused _get_state_for_room
1 parent 3636250 commit 9c75e93

File tree

1 file changed

+0
-110
lines changed

1 file changed

+0
-110
lines changed

synapse/handlers/federation.py

Lines changed: 0 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -441,112 +441,6 @@ async def _get_missing_events_for_pdu(
441441
logger.info("Got %d prev_events", len(missing_events))
442442
await self._process_pulled_events(origin, missing_events, backfilled=False)
443443

444-
async def _get_state_for_room(
445-
self,
446-
destination: str,
447-
room_id: str,
448-
event_id: str,
449-
) -> List[EventBase]:
450-
"""Requests all of the room state at a given event from a remote
451-
homeserver.
452-
453-
Will also fetch any missing events reported in the `auth_chain_ids`
454-
section of `/state_ids`.
455-
456-
Args:
457-
destination: The remote homeserver to query for the state.
458-
room_id: The id of the room we're interested in.
459-
event_id: The id of the event we want the state at.
460-
461-
Returns:
462-
A list of events in the state, not including the event itself.
463-
"""
464-
(
465-
state_event_ids,
466-
auth_event_ids,
467-
) = await self.federation_client.get_room_state_ids(
468-
destination, room_id, event_id=event_id
469-
)
470-
471-
# Fetch the state events from the DB, and check we have the auth events.
472-
event_map = await self.store.get_events(state_event_ids, allow_rejected=True)
473-
auth_events_in_store = await self.store.have_seen_events(
474-
room_id, auth_event_ids
475-
)
476-
477-
# Check for missing events. We handle state and auth event seperately,
478-
# as we want to pull the state from the DB, but we don't for the auth
479-
# events. (Note: we likely won't use the majority of the auth chain, and
480-
# it can be *huge* for large rooms, so it's worth ensuring that we don't
481-
# unnecessarily pull it from the DB).
482-
missing_state_events = set(state_event_ids) - set(event_map)
483-
missing_auth_events = set(auth_event_ids) - set(auth_events_in_store)
484-
if missing_state_events or missing_auth_events:
485-
await self._get_events_and_persist(
486-
destination=destination,
487-
room_id=room_id,
488-
events=missing_state_events | missing_auth_events,
489-
)
490-
491-
if missing_state_events:
492-
new_events = await self.store.get_events(
493-
missing_state_events, allow_rejected=True
494-
)
495-
event_map.update(new_events)
496-
497-
missing_state_events.difference_update(new_events)
498-
499-
if missing_state_events:
500-
logger.warning(
501-
"Failed to fetch missing state events for %s %s",
502-
event_id,
503-
missing_state_events,
504-
)
505-
506-
if missing_auth_events:
507-
auth_events_in_store = await self.store.have_seen_events(
508-
room_id, missing_auth_events
509-
)
510-
missing_auth_events.difference_update(auth_events_in_store)
511-
512-
if missing_auth_events:
513-
logger.warning(
514-
"Failed to fetch missing auth events for %s %s",
515-
event_id,
516-
missing_auth_events,
517-
)
518-
519-
remote_state = list(event_map.values())
520-
521-
# check for events which were in the wrong room.
522-
#
523-
# this can happen if a remote server claims that the state or
524-
# auth_events at an event in room A are actually events in room B
525-
526-
bad_events = [
527-
(event.event_id, event.room_id)
528-
for event in remote_state
529-
if event.room_id != room_id
530-
]
531-
532-
for bad_event_id, bad_room_id in bad_events:
533-
# This is a bogus situation, but since we may only discover it a long time
534-
# after it happened, we try our best to carry on, by just omitting the
535-
# bad events from the returned auth/state set.
536-
logger.warning(
537-
"Remote server %s claims event %s in room %s is an auth/state "
538-
"event in room %s",
539-
destination,
540-
bad_event_id,
541-
bad_room_id,
542-
room_id,
543-
)
544-
545-
if bad_events:
546-
remote_state = [e for e in remote_state if e.room_id == room_id]
547-
548-
return remote_state
549-
550444
async def _get_state_after_missing_prev_event(
551445
self,
552446
destination: str,
@@ -563,10 +457,6 @@ async def _get_state_after_missing_prev_event(
563457
Returns:
564458
A list of events in the state, including the event itself
565459
"""
566-
# TODO: This function is basically the same as _get_state_for_room. Can
567-
# we make backfill() use it, rather than having two code paths? I think the
568-
# only difference is that backfill() persists the prev events separately.
569-
570460
(
571461
state_event_ids,
572462
auth_event_ids,

0 commit comments

Comments
 (0)