summary refs log tree commit diff
path: root/synapse/state.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2015-06-03 16:30:01 +0100
committerErik Johnston <erik@matrix.org>2015-06-03 16:41:51 +0100
commit1c3d844e7314dd5c1722ed77daf4bad8a056217d (patch)
tree3c71d07bcb0f1dcf23df00ff8428982756f11a46 /synapse/state.py
parentLog where a request came from in federation (diff)
downloadsynapse-1c3d844e7314dd5c1722ed77daf4bad8a056217d.tar.xz
Don't needlessly compute context
Diffstat (limited to '')
-rw-r--r--synapse/state.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/synapse/state.py b/synapse/state.py
index 9dddb77d5b..c1ce46d1b2 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,20 @@ class StateHandler(object):
         Returns:
             an EventContext
         """
+        yield run_on_reactor()
+
         context = EventContext()
 
-        yield run_on_reactor()
+        if outlier:
+            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 = {