summary refs log tree commit diff
path: root/synapse/federation/replication.py
diff options
context:
space:
mode:
authorPaul "LeoNerd" Evans <paul@matrix.org>2014-09-15 14:15:10 +0100
committerPaul "LeoNerd" Evans <paul@matrix.org>2014-09-15 14:15:10 +0100
commitb0406b9ead0e3b726ef2c675181d040ca392e85d (patch)
tree42fdeee7d4b5eb283f6a406463499ae05b9e5ffe /synapse/federation/replication.py
parentMerge remote-tracking branch 'origin/develop' into test-sqlite-memory (diff)
parentCorrectly handle the 'age' key in events and pdus (diff)
downloadsynapse-b0406b9ead0e3b726ef2c675181d040ca392e85d.tar.xz
Merge remote-tracking branch 'origin/develop' into test-sqlite-memory
Diffstat (limited to 'synapse/federation/replication.py')
-rw-r--r--synapse/federation/replication.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/synapse/federation/replication.py b/synapse/federation/replication.py
index e12510017f..c79ce44688 100644
--- a/synapse/federation/replication.py
+++ b/synapse/federation/replication.py
@@ -291,6 +291,12 @@ class ReplicationLayer(object):
     def on_incoming_transaction(self, transaction_data):
         transaction = Transaction(**transaction_data)
 
+        for p in transaction.pdus:
+            if "age" in p:
+                p["age_ts"] = int(self.clock.time_msec()) - int(p["age"])
+
+        pdu_list = [Pdu(**p) for p in transaction.pdus]
+
         logger.debug("[%s] Got transaction", transaction.transaction_id)
 
         response = yield self.transaction_actions.have_responded(transaction)
@@ -303,8 +309,6 @@ class ReplicationLayer(object):
 
         logger.debug("[%s] Transacition is new", transaction.transaction_id)
 
-        pdu_list = [Pdu(**p) for p in transaction.pdus]
-
         dl = []
         for pdu in pdu_list:
             dl.append(self._handle_new_pdu(pdu))
@@ -405,9 +409,14 @@ class ReplicationLayer(object):
         """Returns a new Transaction containing the given PDUs suitable for
         transmission.
         """
+        pdus = [p.get_dict() for p in pdu_list]
+        for p in pdus:
+            if "age_ts" in pdus:
+                p["age"] = int(self.clock.time_msec()) - p["age_ts"]
+
         return Transaction(
-            pdus=[p.get_dict() for p in pdu_list],
             origin=self.server_name,
+            pdus=pdus,
             ts=int(self._clock.time_msec()),
             destination=None,
         )