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

Commit 674bdd3

Browse files
committed
requested changes
1 parent a9ce073 commit 674bdd3

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

synapse/events/snapshot.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,8 @@ async def batch_persist_unpersisted_contexts(
363363
"""
364364
Takes a list of events and their associated unpersisted contexts and persists
365365
the unpersisted contexts, returning a list of events and persisted contexts.
366+
Note that all the events must be in a linear chain (ie a <- b <- c)
367+
and must be state events.
366368
367369
Args:
368370
events_and_context: A list of events and their unpersisted contexts

synapse/storage/databases/state/store.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,8 @@ async def store_state_deltas_for_batched(
413413
prev_group: int,
414414
) -> List[Tuple[EventBase, UnpersistedEventContext]]:
415415
"""Generate and store state deltas for a group of events and contexts created to be
416-
batch persisted.
416+
batch persisted. Note that all the events must be in a linear chain (ie a <- b <- c)
417+
and must be state events.
417418
418419
Args:
419420
events_and_context: the events to generate and store a state groups for
@@ -454,8 +455,7 @@ def insert_deltas_group_txn(
454455
txn, num_state_groups
455456
)
456457

457-
index = 0
458-
for event, context in events_and_context:
458+
for index, (event, context) in enumerate(events_and_context):
459459
context.state_group_after_event = state_groups[index]
460460
# The first prev_group will be the last persisted state group, which is passed in
461461
# else it will be the group most recently assigned
@@ -533,8 +533,10 @@ async def store_state_group(
533533
current_state_ids: Optional[StateMap[str]],
534534
) -> int:
535535
"""Store a new set of state, returning a newly assigned state group.
536+
536537
At least one of `current_state_ids` and `prev_group` must be provided. Whenever
537538
`prev_group` is not None, `delta_ids` must also not be None.
539+
538540
Args:
539541
event_id: The event ID for which the state was calculated
540542
room_id
@@ -544,6 +546,7 @@ async def store_state_group(
544546
`current_state_ids`.
545547
current_state_ids: The state to store. Map of (type, state_key)
546548
to event_id.
549+
547550
Returns:
548551
The state group ID
549552
"""

0 commit comments

Comments
 (0)