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

Commit

Permalink
Rename _auth_and_persist_fetched_events (#11116)
Browse files Browse the repository at this point in the history
... to `_auth_and_persist_outliers`, since that reflects its purpose better.
  • Loading branch information
richvdh authored Oct 19, 2021
1 parent d85bc9a commit 0170774
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
1 change: 1 addition & 0 deletions changelog.d/11116.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Clean up some of the federation event authentication code for clarity.
23 changes: 9 additions & 14 deletions synapse/handlers/federation_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -1116,22 +1116,19 @@ async def get_event(event_id: str) -> None:

await concurrently_execute(get_event, event_ids, 5)
logger.info("Fetched %i events of %i requested", len(events), len(event_ids))
await self._auth_and_persist_fetched_events(destination, room_id, events)
await self._auth_and_persist_outliers(room_id, events)

async def _auth_and_persist_fetched_events(
self, origin: str, room_id: str, events: Iterable[EventBase]
async def _auth_and_persist_outliers(
self, room_id: str, events: Iterable[EventBase]
) -> None:
"""Persist the events fetched by _get_events_and_persist or _get_remote_auth_chain_for_event
The events to be persisted must be outliers.
"""Persist a batch of outlier events fetched from remote servers.
We first sort the events to make sure that we process each event's auth_events
before the event itself, and then auth and persist them.
Notifies about the events where appropriate.
Params:
origin: where the events came from
room_id: the room that the events are meant to be in (though this has
not yet been checked)
events: the events that have been fetched
Expand Down Expand Up @@ -1167,15 +1164,15 @@ async def _auth_and_persist_fetched_events(
shortstr(e.event_id for e in roots),
)

await self._auth_and_persist_fetched_events_inner(origin, room_id, roots)
await self._auth_and_persist_outliers_inner(room_id, roots)

for ev in roots:
del event_map[ev.event_id]

async def _auth_and_persist_fetched_events_inner(
self, origin: str, room_id: str, fetched_events: Collection[EventBase]
async def _auth_and_persist_outliers_inner(
self, room_id: str, fetched_events: Collection[EventBase]
) -> None:
"""Helper for _auth_and_persist_fetched_events
"""Helper for _auth_and_persist_outliers
Persists a batch of events where we have (theoretically) already persisted all
of their auth events.
Expand Down Expand Up @@ -1719,9 +1716,7 @@ async def _get_remote_auth_chain_for_event(
for s in seen_remotes:
remote_event_map.pop(s, None)

await self._auth_and_persist_fetched_events(
destination, room_id, remote_event_map.values()
)
await self._auth_and_persist_outliers(room_id, remote_event_map.values())

async def _update_context_for_auth_events(
self, event: EventBase, context: EventContext, auth_events: StateMap[EventBase]
Expand Down

0 comments on commit 0170774

Please sign in to comment.