From 02410e92395f53b88017bf93a82be41afe1a839e Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Tue, 2 Jun 2015 10:58:35 +0100 Subject: [PATCH] Handle the fact we might be missing auth events --- synapse/handlers/federation.py | 36 +++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/synapse/handlers/federation.py b/synapse/handlers/federation.py index ced6fab16..b33317534 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,6 +272,25 @@ class FederationHandler(BaseHandler): set(auth_events.keys()) | set(state_events.keys()) ) + 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.replication_layer.get_pdu( + [dest], + event_id, + outlier=True, + ) + for event_id in missing_auth + ], + consumeErrors=True + ).addErrback(unwrapFirstError) + auth_events.update({a.event_id: a for a in results}) + yield defer.gatherResults( [ self._handle_new_event( @@ -287,22 +307,6 @@ class FederationHandler(BaseHandler): consumeErrors=True, ).addErrback(unwrapFirstError) - yield defer.gatherResults( - [ - self._handle_new_event( - dest, s, - 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 s in state_events.values() - if s.event_id not in seen_events - ], - consumeErrors=True, - ).addErrback(unwrapFirstError) - yield defer.gatherResults( [ self._handle_new_event(