summary refs log tree commit diff
path: root/synapse/state.py
diff options
context:
space:
mode:
authorMark Haines <mark.haines@matrix.org>2014-08-27 15:11:51 +0100
committerMark Haines <mark.haines@matrix.org>2014-08-27 15:11:51 +0100
commita0d1f5a014cf6000cc39231278408789e0019fe8 (patch)
treefbcf3765aea5fc0ed9a0bad99f41a5a195b02d51 /synapse/state.py
parentRemove call to get_federation from homeserver (diff)
downloadsynapse-a0d1f5a014cf6000cc39231278408789e0019fe8.tar.xz
Start updating state handling to use snapshots
Diffstat (limited to 'synapse/state.py')
-rw-r--r--synapse/state.py18
1 files changed, 3 insertions, 15 deletions
diff --git a/synapse/state.py b/synapse/state.py
index ca8e1ca630..e1a1a159bb 100644
--- a/synapse/state.py
+++ b/synapse/state.py
@@ -45,7 +45,7 @@ class StateHandler(object):
 
     @defer.inlineCallbacks
     @log_function
-    def handle_new_event(self, event):
+    def handle_new_event(self, event, snapshot):
         """ Given an event this works out if a) we have sufficient power level
         to update the state and b) works out what the prev_state should be.
 
@@ -70,25 +70,13 @@ class StateHandler(object):
         # Now I need to fill out the prev state and work out if it has auth
         # (w.r.t. to power levels)
 
-        results = yield self.store.get_latest_pdus_in_context(
-            event.room_id
-        )
+        snapshot.fill_out_prev_events(event)
 
         event.prev_events = [
-            encode_event_id(p_id, origin) for p_id, origin, _ in results
-        ]
-        event.prev_events = [
             e for e in event.prev_events if e != event.event_id
         ]
 
-        if results:
-            event.depth = max([int(v) for _, _, v in results]) + 1
-        else:
-            event.depth = 0
-
-        current_state = yield self.store.get_current_state_pdu(
-            key.context, key.type, key.state_key
-        )
+        current_state = snapshot.prev_state_pdu
 
         if current_state:
             event.prev_state = encode_event_id(