summary refs log tree commit diff
path: root/synapse/handlers/federation.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2015-06-02 10:58:35 +0100
committerErik Johnston <erik@matrix.org>2015-06-02 10:58:35 +0100
commit02410e92395f53b88017bf93a82be41afe1a839e (patch)
tree3479b27f747642386dc95bad17d2326f4dbc45e1 /synapse/handlers/federation.py
parentAdd some logging (diff)
downloadsynapse-02410e92395f53b88017bf93a82be41afe1a839e.tar.xz
Handle the fact we might be missing auth events
Diffstat (limited to '')
-rw-r--r--synapse/handlers/federation.py34
1 files changed, 19 insertions, 15 deletions
diff --git a/synapse/handlers/federation.py b/synapse/handlers/federation.py
index ced6fab16f..b333175349 100644
--- a/synapse/handlers/federation.py
+++ b/synapse/handlers/federation.py
@@ -264,6 +264,7 @@ class FederationHandler(BaseHandler):
                 event_id=e_id
             )
             auth_events.update({a.event_id: a for a in auth})
+            auth_events.update({s.event_id: s for s in state})
             state_events.update({s.event_id: s for s in state})
             events_to_state[e_id] = state
 
@@ -271,34 +272,37 @@ class FederationHandler(BaseHandler):
             set(auth_events.keys()) | set(state_events.keys())
         )
 
-        yield defer.gatherResults(
+        all_events = events + state_events.values() + auth_events.values()
+        required_auth = set(
+            a_id for event in all_events for a_id, _ in event.auth_events
+        )
+
+        missing_auth = required_auth - set(auth_events)
+        results = yield defer.gatherResults(
             [
-                self._handle_new_event(
-                    dest, a,
-                    auth_events={
-                        (auth_events[a_id].type, auth_events[a_id].state_key):
-                        auth_events[a_id]
-                        for a_id, _ in a.auth_events
-                    },
+                self.replication_layer.get_pdu(
+                    [dest],
+                    event_id,
+                    outlier=True,
                 )
-                for a in auth_events.values()
-                if a.event_id not in seen_events
+                for event_id in missing_auth
             ],
-            consumeErrors=True,
+            consumeErrors=True
         ).addErrback(unwrapFirstError)
+        auth_events.update({a.event_id: a for a in results})
 
         yield defer.gatherResults(
             [
                 self._handle_new_event(
-                    dest, s,
+                    dest, a,
                     auth_events={
                         (auth_events[a_id].type, auth_events[a_id].state_key):
                         auth_events[a_id]
-                        for a_id, _ in s.auth_events
+                        for a_id, _ in a.auth_events
                     },
                 )
-                for s in state_events.values()
-                if s.event_id not in seen_events
+                for a in auth_events.values()
+                if a.event_id not in seen_events
             ],
             consumeErrors=True,
         ).addErrback(unwrapFirstError)