summary refs log tree commit diff
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2015-06-02 10:11:32 +0100
committerErik Johnston <erik@matrix.org>2015-06-02 10:11:32 +0100
commit3f04a08a0c922962e3a5439b1740424202dc4616 (patch)
tree89d089aa571070e108a6d03b023e8c47d9feedc0
parentCorrectly pass in auth_events (diff)
downloadsynapse-3f04a08a0c922962e3a5439b1740424202dc4616.tar.xz
Don't process events we've already processed. Remember to process state events
-rw-r--r--synapse/handlers/federation.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/synapse/handlers/federation.py b/synapse/handlers/federation.py
index caf6a1f8eb..acbb53d6c5 100644
--- a/synapse/handlers/federation.py
+++ b/synapse/handlers/federation.py
@@ -250,6 +250,7 @@ class FederationHandler(BaseHandler):
         # For each edge get the current state.
 
         auth_events = {}
+        state_events = {}
         events_to_state = {}
         for e_id in edges:
             state, auth = yield self.replication_layer.get_state_for_room(
@@ -258,8 +259,13 @@ class FederationHandler(BaseHandler):
                 event_id=e_id
             )
             auth_events.update({a.event_id: a for a in auth})
+            state_events.update({s.event_id: s for s in state})
             events_to_state[e_id] = state
 
+        seen_events = yield self.store.have_events(
+            set(auth_events.keys()) | set(state_events.keys())
+        )
+
         yield defer.gatherResults(
             [
                 self._handle_new_event(
@@ -270,6 +276,22 @@ class FederationHandler(BaseHandler):
                     }
                 )
                 for a in auth_events.values()
+                if a.event_id not in seen_events
+            ],
+            consumeErrors=True,
+        ).addErrback(unwrapFirstError)
+
+        yield defer.gatherResults(
+            [
+                self._handle_new_event(
+                    dest, s,
+                    auth_events={
+                        (e.type, e.state_key): e for e in auth_events
+                        if e.event_id in [a_id for a_id, _ in s.auth_events]
+                    }
+                )
+                for s in state_events.values()
+                if s.event_id not in seen_events
             ],
             consumeErrors=True,
         ).addErrback(unwrapFirstError)