diff options
author | Erik Johnston <erik@matrix.org> | 2016-08-25 18:59:44 +0100 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2016-08-25 18:59:44 +0100 |
commit | 778fa85f4714c528e73a50af2c1c5fa4f30573eb (patch) | |
tree | fcd5418e00c5d128a7f1613b614afb885dca1a85 /synapse/storage/state.py | |
parent | Fix up push to use get_current_state_ids (diff) | |
download | synapse-778fa85f4714c528e73a50af2c1c5fa4f30573eb.tar.xz |
Make sync not pull out full state
Diffstat (limited to 'synapse/storage/state.py')
-rw-r--r-- | synapse/storage/state.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/synapse/storage/state.py b/synapse/storage/state.py index 22f7fb1aa1..b1d461fef5 100644 --- a/synapse/storage/state.py +++ b/synapse/storage/state.py @@ -284,6 +284,22 @@ class StateStore(SQLBaseStore): defer.returnValue({event: event_to_state[event] for event in event_ids}) @defer.inlineCallbacks + def get_state_ids_for_events(self, event_ids, types): + event_to_groups = yield self._get_state_group_for_events( + event_ids, + ) + + groups = set(event_to_groups.values()) + group_to_state = yield self._get_state_for_groups(groups, types) + + event_to_state = { + event_id: group_to_state[group] + for event_id, group in event_to_groups.items() + } + + defer.returnValue({event: event_to_state[event] for event in event_ids}) + + @defer.inlineCallbacks def get_state_for_event(self, event_id, types=None): """ Get the state dict corresponding to a particular event @@ -300,6 +316,23 @@ class StateStore(SQLBaseStore): state_map = yield self.get_state_for_events([event_id], types) defer.returnValue(state_map[event_id]) + @defer.inlineCallbacks + def get_state_ids_for_event(self, event_id, types=None): + """ + Get the state dict corresponding to a particular event + + Args: + event_id(str): event whose state should be returned + types(list[(str, str)]|None): List of (type, state_key) tuples + which are used to filter the state fetched. May be None, which + matches any key + + Returns: + A deferred dict from (type, state_key) -> state_event + """ + state_map = yield self.get_state_ids_for_events([event_id], types) + defer.returnValue(state_map[event_id]) + @cached(num_args=2, max_entries=10000) def _get_state_group_for_event(self, room_id, event_id): return self._simple_select_one_onecol( |