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

Commit 18e0f49

Browse files
committed
Change to FrozenSet
1 parent 8b49b0f commit 18e0f49

3 files changed

Lines changed: 22 additions & 12 deletions

File tree

synapse/federation/sender/__init__.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,17 @@
1515
import abc
1616
import logging
1717
from collections import OrderedDict
18-
from typing import TYPE_CHECKING, Dict, Hashable, Iterable, List, Optional, Set, Tuple
18+
from typing import (
19+
TYPE_CHECKING,
20+
Collection,
21+
Dict,
22+
Hashable,
23+
Iterable,
24+
List,
25+
Optional,
26+
Set,
27+
Tuple,
28+
)
1929

2030
import attr
2131
from prometheus_client import Counter
@@ -409,7 +419,7 @@ async def handle_event(event: EventBase) -> None:
409419
)
410420
return
411421

412-
destinations: Optional[Set[str]] = None
422+
destinations: Optional[Collection[str]] = None
413423
if not event.prev_event_ids():
414424
# If there are no prev event IDs then the state is empty
415425
# and so no remote servers in the room
@@ -444,7 +454,7 @@ async def handle_event(event: EventBase) -> None:
444454
)
445455
return
446456

447-
destinations = {
457+
sharded_destinations = {
448458
d
449459
for d in destinations
450460
if self._federation_shard_config.should_handle(
@@ -456,12 +466,12 @@ async def handle_event(event: EventBase) -> None:
456466
# If we are sending the event on behalf of another server
457467
# then it already has the event and there is no reason to
458468
# send the event to it.
459-
destinations.discard(send_on_behalf_of)
469+
sharded_destinations.discard(send_on_behalf_of)
460470

461-
logger.debug("Sending %s to %r", event, destinations)
471+
logger.debug("Sending %s to %r", event, sharded_destinations)
462472

463-
if destinations:
464-
await self._send_pdu(event, destinations)
473+
if sharded_destinations:
474+
await self._send_pdu(event, sharded_destinations)
465475

466476
now = self.clock.time_msec()
467477
ts = await self.store.get_received_ts(event.event_id)

synapse/handlers/sync.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -412,9 +412,9 @@ async def current_sync_for_user(
412412

413413
async def push_rules_for_user(self, user: UserID) -> Dict[str, Dict[str, list]]:
414414
user_id = user.to_string()
415-
rules = await self.store.get_push_rules_for_user(user_id)
416-
result = format_push_rules_for_user(user, rules)
417-
return result
415+
rules_raw = await self.store.get_push_rules_for_user(user_id)
416+
rules = format_push_rules_for_user(user, rules_raw )
417+
return rules
418418

419419
async def ephemeral_by_room(
420420
self,

synapse/state/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,13 +239,13 @@ async def get_current_users_in_room(
239239
entry = await self.resolve_state_groups_for_events(room_id, latest_event_ids)
240240
return await self.store.get_joined_users_from_state(room_id, entry)
241241

242-
async def get_current_hosts_in_room(self, room_id: str) -> Set[str]:
242+
async def get_current_hosts_in_room(self, room_id: str) -> FrozenSet[str]:
243243
event_ids = await self.store.get_latest_event_ids_in_room(room_id)
244244
return await self.get_hosts_in_room_at_events(room_id, event_ids)
245245

246246
async def get_hosts_in_room_at_events(
247247
self, room_id: str, event_ids: Collection[str]
248-
) -> Set[str]:
248+
) -> FrozenSet[str]:
249249
"""Get the hosts that were in a room at the given event ids
250250
251251
Args:

0 commit comments

Comments
 (0)