summary refs log tree commit diff
path: root/synapse/handlers/federation.py
diff options
context:
space:
mode:
authorRichard van der Hoff <richard@matrix.org>2019-11-08 12:21:28 +0000
committerRichard van der Hoff <richard@matrix.org>2019-11-08 12:21:28 +0000
commitf41027f74678f35ad9e9eb2531c416dd58a65127 (patch)
tree28aaaedbf6646fc124ffd6b6c02ab567378c4eeb /synapse/handlers/federation.py
parentUpdate some docstrings and comments (diff)
downloadsynapse-f41027f74678f35ad9e9eb2531c416dd58a65127.tar.xz
Use get_events_as_list rather than lots of calls to get_event
It's more efficient and clearer.
Diffstat (limited to '')
-rw-r--r--synapse/handlers/federation.py24
1 files changed, 8 insertions, 16 deletions
diff --git a/synapse/handlers/federation.py b/synapse/handlers/federation.py
index 4bc4d57efb..3d4197ed69 100644
--- a/synapse/handlers/federation.py
+++ b/synapse/handlers/federation.py
@@ -2210,26 +2210,18 @@ class FederationHandler(BaseHandler):
         # idea of them.
 
         room_version = yield self.store.get_room_version(event.room_id)
+        different_event_ids = [
+            d for d in different_auth if d in have_events and not have_events[d]
+        ]
 
-        different_events = yield make_deferred_yieldable(
-            defer.gatherResults(
-                [
-                    run_in_background(
-                        self.store.get_event, d, allow_none=True, allow_rejected=False
-                    )
-                    for d in different_auth
-                    if d in have_events and not have_events[d]
-                ],
-                consumeErrors=True,
-            )
-        ).addErrback(unwrapFirstError)
+        if different_event_ids:
+            # XXX: currently this checks for redactions but I'm not convinced that is
+            # necessary?
+            different_events = yield self.store.get_events_as_list(different_event_ids)
 
-        if different_events:
             local_view = dict(auth_events)
             remote_view = dict(auth_events)
-            remote_view.update(
-                {(d.type, d.state_key): d for d in different_events if d}
-            )
+            remote_view.update({(d.type, d.state_key): d for d in different_events})
 
             new_state = yield self.state_handler.resolve_events(
                 room_version,