summary refs log tree commit diff
path: root/synapse/storage/signatures.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2014-11-12 17:02:18 +0000
committerErik Johnston <erik@matrix.org>2014-11-12 17:02:34 +0000
commitf04b3d5042b85fa81efff9b561ca7af8d9709756 (patch)
tree08a37b4e2d62315f1ea6cd5bd0ccba9630594c12 /synapse/storage/signatures.py
parentAdd more recents service unit tests. (diff)
downloadsynapse-f04b3d5042b85fa81efff9b561ca7af8d9709756.tar.xz
Store all signatures on events rather than just dropping them
Diffstat (limited to 'synapse/storage/signatures.py')
-rw-r--r--synapse/storage/signatures.py24
1 files changed, 15 insertions, 9 deletions
diff --git a/synapse/storage/signatures.py b/synapse/storage/signatures.py
index 84a49088a2..d90e08fff1 100644
--- a/synapse/storage/signatures.py
+++ b/synapse/storage/signatures.py
@@ -103,24 +103,30 @@ class SignatureStore(SQLBaseStore):
             or_ignore=True,
         )
 
-
-    def _get_event_origin_signatures_txn(self, txn, event_id):
+    def _get_event_signatures_txn(self, txn, event_id):
         """Get all the signatures for a given PDU.
         Args:
             txn (cursor):
             event_id (str): Id for the Event.
         Returns:
-            A dict of key_id -> signature_bytes.
+            A dict of sig name -> dict(key_id -> signature_bytes)
         """
         query = (
-            "SELECT key_id, signature"
-            " FROM event_origin_signatures"
+            "SELECT signature_name, key_id, signature"
+            " FROM event_signatures"
             " WHERE event_id = ? "
         )
         txn.execute(query, (event_id, ))
-        return dict(txn.fetchall())
+        rows = txn.fetchall()
+
+        res = {}
+
+        for name, key, sig in rows:
+            res.setdefault(name, {})[key] = sig
+
+        return res
 
-    def _store_event_origin_signature_txn(self, txn, event_id, origin, key_id,
+    def _store_event_signature_txn(self, txn, event_id, signature_name, key_id,
                                           signature_bytes):
         """Store a signature from the origin server for a PDU.
         Args:
@@ -132,10 +138,10 @@ class SignatureStore(SQLBaseStore):
         """
         self._simple_insert_txn(
             txn,
-            "event_origin_signatures",
+            "event_signatures",
             {
                 "event_id": event_id,
-                "origin": origin,
+                "signature_name": signature_name,
                 "key_id": key_id,
                 "signature": buffer(signature_bytes),
             },