diff options
author | Erik Johnston <erik@matrix.org> | 2015-06-03 17:20:40 +0100 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2015-06-03 17:20:40 +0100 |
commit | 9dda396baa957f2ea2b871955e5c01c6ad0deee1 (patch) | |
tree | fd6b3bb05b0d2c54e808c9e264d0b36437e9dd23 /synapse/state.py | |
parent | Merge pull request #178 from matrix-org/erikj/cache_state_groups (diff) | |
parent | Comment (diff) | |
download | synapse-9dda396baa957f2ea2b871955e5c01c6ad0deee1.tar.xz |
Merge pull request #179 from matrix-org/erikj/state_group_outliers
Don't compute EventContext for outliers.
Diffstat (limited to 'synapse/state.py')
-rw-r--r-- | synapse/state.py | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/synapse/state.py b/synapse/state.py index 9dddb77d5b..8a635f1cc1 100644 --- a/synapse/state.py +++ b/synapse/state.py @@ -106,7 +106,7 @@ class StateHandler(object): defer.returnValue(state) @defer.inlineCallbacks - def compute_event_context(self, event, old_state=None): + def compute_event_context(self, event, old_state=None, outlier=False): """ Fills out the context with the `current state` of the graph. The `current state` here is defined to be the state of the event graph just before the event - i.e. it never includes `event` @@ -119,9 +119,23 @@ class StateHandler(object): Returns: an EventContext """ + yield run_on_reactor() + context = EventContext() - yield run_on_reactor() + if outlier: + # If this is an outlier, then we know it shouldn't have any current + # state. Certainly store.get_current_state won't return any, and + # persisting the event won't store the state group. + if old_state: + context.current_state = { + (s.type, s.state_key): s for s in old_state + } + else: + context.current_state = {} + context.prev_state_events = [] + context.state_group = None + defer.returnValue(context) if old_state: context.current_state = { |