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

Commit

Permalink
Handle delta_ids being None in _update_context_for_auth_events
Browse files Browse the repository at this point in the history
it's easier to create the new state group as a delta from the existing one.

(There's an outside chance this will help with
#3364)
  • Loading branch information
richvdh committed Jul 23, 2018
1 parent cc99256 commit c1f80ef
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
3 changes: 2 additions & 1 deletion synapse/events/snapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ def _fill_out_state(self, store):

@defer.inlineCallbacks
def update_state(self, state_group, prev_state_ids, current_state_ids,
delta_ids):
prev_group, delta_ids):
"""Replace the state in the context
"""

Expand All @@ -260,6 +260,7 @@ def update_state(self, state_group, prev_state_ids, current_state_ids,

self.state_group = state_group
self._prev_state_ids = prev_state_ids
self.prev_group = prev_group
self._current_state_ids = current_state_ids
self.delta_ids = delta_ids

Expand Down
13 changes: 6 additions & 7 deletions synapse/handlers/federation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1980,30 +1980,29 @@ def _update_context_for_auth_events(self, event, context, auth_events,

current_state_ids.update(state_updates)

if context.delta_ids is not None:
delta_ids = dict(context.delta_ids)
delta_ids.update(state_updates)

prev_state_ids = yield context.get_prev_state_ids(self.store)
prev_state_ids = dict(prev_state_ids)

prev_state_ids.update({
k: a.event_id for k, a in iteritems(auth_events)
})

# create a new state group as a delta from the existing one.
prev_group = context.state_group
state_group = yield self.store.store_state_group(
event.event_id,
event.room_id,
prev_group=context.prev_group,
delta_ids=delta_ids,
prev_group=prev_group,
delta_ids=state_updates,
current_state_ids=current_state_ids,
)

yield context.update_state(
state_group=state_group,
current_state_ids=current_state_ids,
prev_state_ids=prev_state_ids,
delta_ids=delta_ids,
prev_group=prev_group,
delta_ids=state_updates,
)

@defer.inlineCallbacks
Expand Down

0 comments on commit c1f80ef

Please sign in to comment.