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

Commit 4660d9f

Browse files
authored
Fix up state_store naming (#12871)
1 parent a8db8c6 commit 4660d9f

File tree

15 files changed

+58
-49
lines changed

15 files changed

+58
-49
lines changed

changelog.d/12871.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix up the variable `state_store` naming.

synapse/handlers/admin.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class AdminHandler:
3131
def __init__(self, hs: "HomeServer"):
3232
self.store = hs.get_datastores().main
3333
self.storage = hs.get_storage()
34-
self.state_store = self.storage.state
34+
self.state_storage = self.storage.state
3535

3636
async def get_whois(self, user: UserID) -> JsonDict:
3737
connections = []
@@ -233,7 +233,7 @@ async def export_user_data(self, user_id: str, writer: "ExfiltrationWriter") ->
233233
for event_id in extremities:
234234
if not event_to_unseen_prevs[event_id]:
235235
continue
236-
state = await self.state_store.get_state_for_event(event_id)
236+
state = await self.state_storage.get_state_for_event(event_id)
237237
writer.write_state(room_id, event_id, state)
238238

239239
return writer.finished()

synapse/handlers/device.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def __init__(self, hs: "HomeServer"):
7070
self.store = hs.get_datastores().main
7171
self.notifier = hs.get_notifier()
7272
self.state = hs.get_state_handler()
73-
self.state_store = hs.get_storage().state
73+
self.state_storage = hs.get_storage().state
7474
self._auth_handler = hs.get_auth_handler()
7575
self.server_name = hs.hostname
7676

@@ -203,7 +203,9 @@ async def get_user_ids_changed(
203203
continue
204204

205205
# mapping from event_id -> state_dict
206-
prev_state_ids = await self.state_store.get_state_ids_for_events(event_ids)
206+
prev_state_ids = await self.state_storage.get_state_ids_for_events(
207+
event_ids
208+
)
207209

208210
# Check if we've joined the room? If so we just blindly add all the users to
209211
# the "possibly changed" users.

synapse/handlers/federation.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def __init__(self, hs: "HomeServer"):
126126

127127
self.store = hs.get_datastores().main
128128
self.storage = hs.get_storage()
129-
self.state_store = self.storage.state
129+
self.state_storage = self.storage.state
130130
self.federation_client = hs.get_federation_client()
131131
self.state_handler = hs.get_state_handler()
132132
self.server_name = hs.hostname
@@ -1027,7 +1027,9 @@ async def get_state_ids_for_pdu(self, room_id: str, event_id: str) -> List[str]:
10271027
if event.internal_metadata.outlier:
10281028
raise NotFoundError("State not known at event %s" % (event_id,))
10291029

1030-
state_groups = await self.state_store.get_state_groups_ids(room_id, [event_id])
1030+
state_groups = await self.state_storage.get_state_groups_ids(
1031+
room_id, [event_id]
1032+
)
10311033

10321034
# get_state_groups_ids should return exactly one result
10331035
assert len(state_groups) == 1

synapse/handlers/federation_event.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ class FederationEventHandler:
9999
def __init__(self, hs: "HomeServer"):
100100
self._store = hs.get_datastores().main
101101
self._storage = hs.get_storage()
102-
self._state_store = self._storage.state
102+
self._state_storage = self._storage.state
103103

104104
self._state_handler = hs.get_state_handler()
105105
self._event_creation_handler = hs.get_event_creation_handler()
@@ -533,7 +533,7 @@ async def update_state_for_partial_state_event(
533533
)
534534
return
535535
await self._store.update_state_for_partial_state_event(event, context)
536-
self._state_store.notify_event_un_partial_stated(event.event_id)
536+
self._state_storage.notify_event_un_partial_stated(event.event_id)
537537

538538
async def backfill(
539539
self, dest: str, room_id: str, limit: int, extremities: Collection[str]
@@ -832,7 +832,7 @@ async def _resolve_state_at_missing_prevs(
832832
event_map = {event_id: event}
833833
try:
834834
# Get the state of the events we know about
835-
ours = await self._state_store.get_state_groups_ids(room_id, seen)
835+
ours = await self._state_storage.get_state_groups_ids(room_id, seen)
836836

837837
# state_maps is a list of mappings from (type, state_key) to event_id
838838
state_maps: List[StateMap[str]] = list(ours.values())
@@ -1626,7 +1626,7 @@ async def _check_for_soft_fail(
16261626
# given state at the event. This should correctly handle cases
16271627
# like bans, especially with state res v2.
16281628

1629-
state_sets_d = await self._state_store.get_state_groups(
1629+
state_sets_d = await self._state_storage.get_state_groups(
16301630
event.room_id, extrem_ids
16311631
)
16321632
state_sets: List[Iterable[EventBase]] = list(state_sets_d.values())
@@ -1895,7 +1895,7 @@ async def _update_context_for_auth_events(
18951895

18961896
# create a new state group as a delta from the existing one.
18971897
prev_group = context.state_group
1898-
state_group = await self._state_store.store_state_group(
1898+
state_group = await self._state_storage.store_state_group(
18991899
event.event_id,
19001900
event.room_id,
19011901
prev_group=prev_group,

synapse/handlers/initial_sync.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def __init__(self, hs: "HomeServer"):
6868
] = ResponseCache(hs.get_clock(), "initial_sync_cache")
6969
self._event_serializer = hs.get_event_client_serializer()
7070
self.storage = hs.get_storage()
71-
self.state_store = self.storage.state
71+
self.state_storage = self.storage.state
7272

7373
async def snapshot_all_rooms(
7474
self,
@@ -198,7 +198,7 @@ async def handle_room(event: RoomsForUser) -> None:
198198
event.stream_ordering,
199199
)
200200
deferred_room_state = run_in_background(
201-
self.state_store.get_state_for_events, [event.event_id]
201+
self.state_storage.get_state_for_events, [event.event_id]
202202
).addCallback(
203203
lambda states: cast(StateMap[EventBase], states[event.event_id])
204204
)
@@ -355,7 +355,7 @@ async def _room_initial_sync_parted(
355355
member_event_id: str,
356356
is_peeking: bool,
357357
) -> JsonDict:
358-
room_state = await self.state_store.get_state_for_event(member_event_id)
358+
room_state = await self.state_storage.get_state_for_event(member_event_id)
359359

360360
limit = pagin_config.limit if pagin_config else None
361361
if limit is None:

synapse/handlers/message.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def __init__(self, hs: "HomeServer"):
7878
self.state = hs.get_state_handler()
7979
self.store = hs.get_datastores().main
8080
self.storage = hs.get_storage()
81-
self.state_store = self.storage.state
81+
self.state_storage = self.storage.state
8282
self._event_serializer = hs.get_event_client_serializer()
8383
self._ephemeral_events_enabled = hs.config.server.enable_ephemeral_messages
8484

@@ -125,7 +125,7 @@ async def get_room_data(
125125
assert (
126126
membership_event_id is not None
127127
), "check_user_in_room_or_world_readable returned invalid data"
128-
room_state = await self.state_store.get_state_for_events(
128+
room_state = await self.state_storage.get_state_for_events(
129129
[membership_event_id], StateFilter.from_types([key])
130130
)
131131
data = room_state[membership_event_id].get(key)
@@ -186,7 +186,7 @@ async def get_state_events(
186186

187187
# check whether the user is in the room at that time to determine
188188
# whether they should be treated as peeking.
189-
state_map = await self.state_store.get_state_for_event(
189+
state_map = await self.state_storage.get_state_for_event(
190190
last_event.event_id,
191191
StateFilter.from_types([(EventTypes.Member, user_id)]),
192192
)
@@ -207,7 +207,7 @@ async def get_state_events(
207207
)
208208

209209
if visible_events:
210-
room_state_events = await self.state_store.get_state_for_events(
210+
room_state_events = await self.state_storage.get_state_for_events(
211211
[last_event.event_id], state_filter=state_filter
212212
)
213213
room_state: Mapping[Any, EventBase] = room_state_events[
@@ -237,7 +237,7 @@ async def get_state_events(
237237
assert (
238238
membership_event_id is not None
239239
), "check_user_in_room_or_world_readable returned invalid data"
240-
room_state_events = await self.state_store.get_state_for_events(
240+
room_state_events = await self.state_storage.get_state_for_events(
241241
[membership_event_id], state_filter=state_filter
242242
)
243243
room_state = room_state_events[membership_event_id]

synapse/handlers/pagination.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def __init__(self, hs: "HomeServer"):
130130
self.auth = hs.get_auth()
131131
self.store = hs.get_datastores().main
132132
self.storage = hs.get_storage()
133-
self.state_store = self.storage.state
133+
self.state_storage = self.storage.state
134134
self.clock = hs.get_clock()
135135
self._server_name = hs.hostname
136136
self._room_shutdown_handler = hs.get_room_shutdown_handler()
@@ -539,7 +539,7 @@ async def get_messages(
539539
(EventTypes.Member, event.sender) for event in events
540540
)
541541

542-
state_ids = await self.state_store.get_state_ids_for_event(
542+
state_ids = await self.state_storage.get_state_ids_for_event(
543543
events[0].event_id, state_filter=state_filter
544544
)
545545

synapse/handlers/room.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,7 +1193,7 @@ def __init__(self, hs: "HomeServer"):
11931193
self.auth = hs.get_auth()
11941194
self.store = hs.get_datastores().main
11951195
self.storage = hs.get_storage()
1196-
self.state_store = self.storage.state
1196+
self.state_storage = self.storage.state
11971197
self._relations_handler = hs.get_relations_handler()
11981198

11991199
async def get_event_context(
@@ -1293,7 +1293,7 @@ async def filter_evts(events: List[EventBase]) -> List[EventBase]:
12931293
# first? Shouldn't we be consistent with /sync?
12941294
# https://github.com/matrix-org/matrix-doc/issues/687
12951295

1296-
state = await self.state_store.get_state_for_events(
1296+
state = await self.state_storage.get_state_for_events(
12971297
[last_event_id], state_filter=state_filter
12981298
)
12991299

synapse/handlers/room_batch.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class RoomBatchHandler:
1717
def __init__(self, hs: "HomeServer"):
1818
self.hs = hs
1919
self.store = hs.get_datastores().main
20-
self.state_store = hs.get_storage().state
20+
self.state_storage = hs.get_storage().state
2121
self.event_creation_handler = hs.get_event_creation_handler()
2222
self.room_member_handler = hs.get_room_member_handler()
2323
self.auth = hs.get_auth()
@@ -141,7 +141,7 @@ async def get_most_recent_full_state_ids_from_event_id_list(
141141
) = await self.store.get_max_depth_of(event_ids)
142142
# mapping from (type, state_key) -> state_event_id
143143
assert most_recent_event_id is not None
144-
prev_state_map = await self.state_store.get_state_ids_for_event(
144+
prev_state_map = await self.state_storage.get_state_ids_for_event(
145145
most_recent_event_id
146146
)
147147
# List of state event ID's

0 commit comments

Comments
 (0)