summary refs log tree commit diff
path: root/synapse/storage/event_federation.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2014-11-05 13:23:35 +0000
committerErik Johnston <erik@matrix.org>2014-11-05 13:23:35 +0000
commitcc44ecc62f69436a9217745292af6c55b5f8fe81 (patch)
treeb464e587fe4309e0bb1460822180a99fd12f6dbc /synapse/storage/event_federation.py
parentFix typing tests (diff)
downloadsynapse-cc44ecc62f69436a9217745292af6c55b5f8fe81.tar.xz
Get correct prev_events
Diffstat (limited to 'synapse/storage/event_federation.py')
-rw-r--r--synapse/storage/event_federation.py30
1 files changed, 21 insertions, 9 deletions
diff --git a/synapse/storage/event_federation.py b/synapse/storage/event_federation.py
index dcc116bad2..f427aba879 100644
--- a/synapse/storage/event_federation.py
+++ b/synapse/storage/event_federation.py
@@ -49,15 +49,6 @@ class EventFederationStore(SQLBaseStore):
         )
 
     def _get_latest_events_in_room(self, txn, room_id):
-        self._simple_select_onecol_txn(
-            txn,
-            table="event_forward_extremities",
-            keyvalues={
-                "room_id": room_id,
-            },
-            retcol="event_id",
-        )
-
         sql = (
             "SELECT e.event_id, e.depth FROM events as e "
             "INNER JOIN event_forward_extremities as f "
@@ -78,6 +69,27 @@ class EventFederationStore(SQLBaseStore):
 
         return results
 
+    def _get_prev_events(self, txn, event_id):
+        prev_ids = self._simple_select_onecol_txn(
+            txn,
+            table="event_edges",
+            keyvalues={
+                "event_id": event_id,
+            },
+            retcol="prev_event_id",
+        )
+
+        results = []
+        for prev_event_id in prev_ids:
+            hashes = self._get_event_reference_hashes_txn(txn, prev_event_id)
+            prev_hashes = {
+                k: encode_base64(v) for k, v in hashes.items()
+                if k == "sha256"
+            }
+            results.append((event_id, prev_hashes))
+
+        return results
+
     def get_min_depth(self, room_id):
         return self.runInteraction(
             "get_min_depth",