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

Define StateMap as immutable and add a MutableStateMap type. #8183

Merged
merged 5 commits into from
Aug 28, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions synapse/state/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
Sequence,
Set,
Union,
cast,
overload,
)

Expand Down Expand Up @@ -554,16 +555,20 @@ async def resolve_state_groups(
if conflicted_state:
logger.info("Resolving conflicted state for %r", room_id)
with Measure(self.clock, "state._resolve_events"):
# mypy doesn't like that new_state was previously mutable,
# and now isn't. We don't mutate past this point though, so
# tell it to go away.
new_state = await resolve_events_with_store( # type: ignore
self.clock,
room_id,
room_version,
list(state_groups_ids.values()),
event_map=event_map,
state_res_store=state_res_store,
# resolve_eevnts_with_store returns a StateMap, but we can
clokep marked this conversation as resolved.
Show resolved Hide resolved
# treat it as a MutableStateMap as it is above. It isn't
# actually mutated anymore (and is frozen in
# _make_state_cache_entry below).
new_state = cast(
MutableStateMap,
await resolve_events_with_store(
self.clock,
room_id,
room_version,
list(state_groups_ids.values()),
event_map=event_map,
state_res_store=state_res_store,
),
)

# if the new state matches any of the input state groups, we can
Expand Down