summary refs log tree commit diff
path: root/synapse/federation/replication.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2014-09-15 14:54:25 +0100
committerErik Johnston <erik@matrix.org>2014-09-15 16:24:03 +0100
commit6ac0b4ade86d1bdb59c01ff8edff6b149cf1981e (patch)
tree7915ed694672d932f3537b8136ed4ba20f8650da /synapse/federation/replication.py
parentMore helpful 400 error messages. (diff)
downloadsynapse-6ac0b4ade86d1bdb59c01ff8edff6b149cf1981e.tar.xz
Fix 'age' key to update on retries
Diffstat (limited to 'synapse/federation/replication.py')
-rw-r--r--synapse/federation/replication.py19
1 files changed, 16 insertions, 3 deletions
diff --git a/synapse/federation/replication.py b/synapse/federation/replication.py
index c79ce44688..a48a7ac15f 100644
--- a/synapse/federation/replication.py
+++ b/synapse/federation/replication.py
@@ -292,8 +292,8 @@ class ReplicationLayer(object):
         transaction = Transaction(**transaction_data)
 
         for p in transaction.pdus:
-            if "age" in p:
-                p["age_ts"] = int(self.clock.time_msec()) - int(p["age"])
+            if "age_ts" in p:
+                p["age"] = int(self._clock.time_msec()) - int(p["age_ts"])
 
         pdu_list = [Pdu(**p) for p in transaction.pdus]
 
@@ -602,8 +602,21 @@ class _TransactionQueue(object):
             logger.debug("TX [%s] Sending transaction...", destination)
 
             # Actually send the transaction
+
+            # FIXME (erikj): This is a bit of a hack to make the Pdu age
+            # keys work
+            def cb(transaction):
+                now = int(self._clock.time_msec())
+                if "pdus" in transaction:
+                    for p in transaction["pdus"]:
+                        if "age_ts" in p:
+                            p["age"] = now - int(p["age_ts"])
+
+                return transaction
+
             code, response = yield self.transport_layer.send_transaction(
-                transaction
+                transaction,
+                on_send_callback=cb,
             )
 
             logger.debug("TX [%s] Sent transaction", destination)