diff options
author | Erik Johnston <erik@matrix.org> | 2015-02-12 18:35:36 +0000 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2015-02-12 18:35:36 +0000 |
commit | 58d848adc0ee9ab8e44a780a19be1e46e0d5cec3 (patch) | |
tree | ed45976aff6f2f611b3395efa3af2bd300065d78 /synapse/federation | |
parent | Correctly handle all the places that can throw exceptions (diff) | |
download | synapse-58d848adc0ee9ab8e44a780a19be1e46e0d5cec3.tar.xz |
Parrellize fetching of events
Diffstat (limited to '')
-rw-r--r-- | synapse/federation/federation_base.py | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/synapse/federation/federation_base.py b/synapse/federation/federation_base.py index 30f3f5c8a4..966f4d2c5c 100644 --- a/synapse/federation/federation_base.py +++ b/synapse/federation/federation_base.py @@ -50,8 +50,11 @@ class FederationBase(object): Returns: Deferred : A list of PDUs that have valid signatures and hashes. """ + signed_pdus = [] - for pdu in pdus: + + @defer.inlineCallbacks + def do(pdu): try: new_pdu = yield self._check_sigs_and_hash(pdu) signed_pdus.append(new_pdu) @@ -66,7 +69,7 @@ class FederationBase(object): ) if new_pdu: signed_pdus.append(new_pdu) - continue + return # Check pdu.origin if pdu.origin != origin: @@ -79,12 +82,17 @@ class FederationBase(object): if new_pdu: signed_pdus.append(new_pdu) - continue + return except: pass logger.warn("Failed to find copy of %s with valid signature") + yield defer.gatherResults( + [do(pdu) for pdu in pdus], + consumeErrors=True + ) + defer.returnValue(signed_pdus) @defer.inlineCallbacks |