summary refs log tree commit diff
path: root/synapse/crypto
diff options
context:
space:
mode:
authorRichard van der Hoff <richard@matrix.org>2017-09-20 01:32:42 +0100
committerRichard van der Hoff <richard@matrix.org>2017-09-20 01:32:42 +0100
commit3b98439ecaab4707c2224d7912b3f4513c2af8b7 (patch)
tree2017cc61e9bf7142b91b0525b75ad72b1e1e4789 /synapse/crypto
parentReplace `server_and_json` with `verify_requests` (diff)
downloadsynapse-3b98439ecaab4707c2224d7912b3f4513c2af8b7.tar.xz
Factor out _start_key_lookups
... to make it easier to see what's going on.
Diffstat (limited to 'synapse/crypto')
-rw-r--r--synapse/crypto/keyring.py24
1 files changed, 17 insertions, 7 deletions
diff --git a/synapse/crypto/keyring.py b/synapse/crypto/keyring.py
index 32b107b17d..105de2b58b 100644
--- a/synapse/crypto/keyring.py
+++ b/synapse/crypto/keyring.py
@@ -122,6 +122,23 @@ class Keyring(object):
 
             verify_requests.append(verify_request)
 
+        self._start_key_lookups(verify_requests)
+
+        # Pass those keys to handle_key_deferred so that the json object
+        # signatures can be verified
+        return [
+            preserve_context_over_fn(_handle_key_deferred, rq)
+            for rq in verify_requests
+        ]
+
+    def _start_key_lookups(self, verify_requests):
+        """Sets off the key fetches for each verify request
+
+        Once each fetch completes, verify_request.deferred will be resolved.
+
+        Args:
+            verify_requests (List[VerifyKeyRequest]):
+        """
         server_to_deferred = {
             rq.server_name: defer.Deferred()
             for rq in verify_requests
@@ -163,13 +180,6 @@ class Keyring(object):
                     remove_deferreds, server_name, verify_request,
                 )
 
-        # Pass those keys to handle_key_deferred so that the json object
-        # signatures can be verified
-        return [
-            preserve_context_over_fn(_handle_key_deferred, verify_request)
-            for verify_request in verify_requests
-        ]
-
     @defer.inlineCallbacks
     def wait_for_previous_lookups(self, server_names, server_to_deferred):
         """Waits for any previous key lookups for the given servers to finish.