summary refs log tree commit diff
path: root/synapse/federation/persistence.py
diff options
context:
space:
mode:
authorMark Haines <mark.haines@matrix.org>2014-08-26 18:01:36 +0100
committerMark Haines <mark.haines@matrix.org>2014-08-26 18:01:36 +0100
commit64e2a5d58ef6ec38019f97318bf97f8b9bffddcb (patch)
tree4315ec68c34f996845db6f8f23ccc3d4c8504b78 /synapse/federation/persistence.py
parentMerge branch 'develop' into storage_transactions (diff)
downloadsynapse-64e2a5d58ef6ec38019f97318bf97f8b9bffddcb.tar.xz
Move pdu and event persistence into a single persist_event function
Diffstat (limited to 'synapse/federation/persistence.py')
-rw-r--r--synapse/federation/persistence.py30
1 files changed, 2 insertions, 28 deletions
diff --git a/synapse/federation/persistence.py b/synapse/federation/persistence.py
index e0e4de4e8c..76d37a0c52 100644
--- a/synapse/federation/persistence.py
+++ b/synapse/federation/persistence.py
@@ -25,7 +25,6 @@ from .units import Pdu
 
 from synapse.util.logutils import log_function
 
-import copy
 import json
 import logging
 
@@ -48,9 +47,8 @@ class PduActions(object):
         Returns:
             Deferred
         """
-        return self._persist(pdu)
+        return self.store.persist_event(pdu=pdu)
 
-    @defer.inlineCallbacks
     @log_function
     def persist_outgoing(self, pdu):
         """ Persists the given `Pdu` that this home server created.
@@ -58,9 +56,7 @@ class PduActions(object):
         Returns:
             Deferred
         """
-        ret = yield self._persist(pdu)
-
-        defer.returnValue(ret)
+        return self.store.persist_event(pdu=pdu)
 
     @log_function
     def mark_as_processed(self, pdu):
@@ -143,28 +139,6 @@ class PduActions(object):
             depth=pdu.depth
         )
 
-    @defer.inlineCallbacks
-    @log_function
-    def _persist(self, pdu):
-        kwargs = copy.copy(pdu.__dict__)
-        unrec_keys = copy.copy(pdu.unrecognized_keys)
-        del kwargs["content"]
-        kwargs["content_json"] = json.dumps(pdu.content)
-        kwargs["unrecognized_keys"] = json.dumps(unrec_keys)
-
-        logger.debug("Persisting: %s", repr(kwargs))
-
-        if pdu.is_state:
-            ret = yield self.store.persist_state(**kwargs)
-        else:
-            ret = yield self.store.persist_pdu(**kwargs)
-
-        yield self.store.update_min_depth_for_context(
-            pdu.context, pdu.depth
-        )
-
-        defer.returnValue(ret)
-
 
 class TransactionActions(object):
     """ Defines persistence actions that relate to handling Transactions.