@@ -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