summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--keymanager/changes/VERSION_COMPAT1
-rw-r--r--keymanager/changes/feature_4784-memoize-get-key1
-rw-r--r--keymanager/src/leap/keymanager/__init__.py7
3 files changed, 7 insertions, 2 deletions
diff --git a/keymanager/changes/VERSION_COMPAT b/keymanager/changes/VERSION_COMPAT
index e69de29b..dfe67ab4 100644
--- a/keymanager/changes/VERSION_COMPAT
+++ b/keymanager/changes/VERSION_COMPAT
@@ -0,0 +1 @@
+leap.common >= 0.3.7 # memoize
diff --git a/keymanager/changes/feature_4784-memoize-get-key b/keymanager/changes/feature_4784-memoize-get-key
new file mode 100644
index 00000000..52848278
--- /dev/null
+++ b/keymanager/changes/feature_4784-memoize-get-key
@@ -0,0 +1 @@
+ o Memoize call to get_key. Closes: #4784
diff --git a/keymanager/src/leap/keymanager/__init__.py b/keymanager/src/leap/keymanager/__init__.py
index 6cfbf710..5b1d8d96 100644
--- a/keymanager/src/leap/keymanager/__init__.py
+++ b/keymanager/src/leap/keymanager/__init__.py
@@ -46,6 +46,7 @@ import requests
from leap.common.check import leap_assert, leap_assert_type
from leap.common.events import signal
from leap.common.events import events_pb2 as proto
+from leap.common.decorators import memoized_method
from leap.keymanager.errors import KeyNotFound
@@ -250,6 +251,7 @@ class KeyManager(object):
self._put(uri, data)
signal(proto.KEYMANAGER_DONE_UPLOADING_KEYS, self._address)
+ @memoized_method
def get_key(self, address, ktype, private=False, fetch_remote=True):
"""
Return a key of type C{ktype} bound to C{address}.
@@ -266,9 +268,10 @@ class KeyManager(object):
:return: A key of type C{ktype} bound to C{address}.
:rtype: EncryptionKey
- @raise KeyNotFound: If the key was not found both locally and in
- keyserver.
+ :raise KeyNotFound: If the key was not found both locally and in
+ keyserver.
"""
+ logger.debug("getting key for %s" % (address,))
leap_assert(
ktype in self._wrapper_map,
'Unkown key type: %s.' % str(ktype))