From a8e130afdb4a1070d82f47e26990d34f41bd8753 Mon Sep 17 00:00:00 2001 From: Inso <insomniak.fr@gmail.com> Date: Tue, 14 Jul 2015 14:43:08 +0200 Subject: [PATCH] Replacing future_lookup with future_find #178 --- src/cutecoin/core/account.py | 6 +++--- src/cutecoin/core/net/api/bma/__init__.py | 4 ++-- src/cutecoin/core/registry/identities.py | 4 ++-- src/cutecoin/core/txhistory.py | 4 ++-- src/cutecoin/core/wallet.py | 4 ++-- src/cutecoin/gui/community_tab.py | 2 +- src/cutecoin/gui/process_cfg_community.py | 2 +- src/cutecoin/tests/stubs/core/registry/identities.py | 2 +- 8 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/cutecoin/core/account.py b/src/cutecoin/core/account.py index a7dafaec..a0802e38 100644 --- a/src/cutecoin/core/account.py +++ b/src/cutecoin/core/account.py @@ -442,7 +442,7 @@ class Account(QObject): logging.debug("Send membership") blockid = yield from community.blockid() - self_identity = yield from self._identities_registry.future_lookup(self.pubkey, community) + self_identity = yield from self._identities_registry.future_find(self.pubkey, community) selfcert = yield from self_identity.selfcert(community) membership = Membership(PROTOCOL_VERSION, community.currency, @@ -495,7 +495,7 @@ class Account(QObject): """ logging.debug("Certdata") blockid = yield from community.blockid() - identity = yield from self._identities_registry.future_lookup(pubkey, community) + identity = yield from self._identities_registry.future_find(pubkey, community) selfcert = yield from identity.selfcert(community) certification = Certification(PROTOCOL_VERSION, community.currency, self.pubkey, pubkey, @@ -549,7 +549,7 @@ class Account(QObject): :param str password: The account SigningKey password :param cutecoin.core.community.Community community: The community target of the revocation """ - revoked = yield from self._identities_registry.future_lookup(self.pubkey, community) + revoked = yield from self._identities_registry.future_find(self.pubkey, community) revocation = Revocation(PROTOCOL_VERSION, community.currency, None) selfcert = revoked.selfcert(community) diff --git a/src/cutecoin/core/net/api/bma/__init__.py b/src/cutecoin/core/net/api/bma/__init__.py index 12e54f5c..00af271a 100644 --- a/src/cutecoin/core/net/api/bma/__init__.py +++ b/src/cutecoin/core/net/api/bma/__init__.py @@ -13,10 +13,10 @@ PROTOCOL_VERSION = "1" @asyncio.coroutine def timeout(reply, seconds): - logging.debug("Sleep timeout...") + #logging.debug("Sleep timeout...") yield from asyncio.sleep(seconds) if reply.isRunning(): - logging.debug("Reply aborted because of timeout") + #logging.debug("Reply aborted because of timeout") reply.abort() diff --git a/src/cutecoin/core/registry/identities.py b/src/cutecoin/core/registry/identities.py index 12eb705a..42ab2855 100644 --- a/src/cutecoin/core/registry/identities.py +++ b/src/cutecoin/core/registry/identities.py @@ -87,7 +87,7 @@ class IdentitiesRegistry: reply = community.bma_access.simple_request(qtbma.wot.CertifiersOf, req_args={'search': pubkey}) reply.finished.connect(lambda: handle_certifiersof_reply(reply, tries=tries+1)) else: - future_identity.set_result(False) + future_identity.set_result(True) def handle_lookup_reply(reply, tries=0): status_code = reply.attribute(QNetworkRequest.HttpStatusCodeAttribute) @@ -114,7 +114,7 @@ class IdentitiesRegistry: reply = community.bma_access.simple_request(qtbma.wot.Lookup, req_args={'search': pubkey}) reply.finished.connect(lambda: handle_lookup_reply(reply, tries=tries+1)) else: - future_identity.set_result(False) + future_identity.set_result(True) future_identity = asyncio.Future() if pubkey in self._instances: diff --git a/src/cutecoin/core/txhistory.py b/src/cutecoin/core/txhistory.py index 4824f325..5f434d62 100644 --- a/src/cutecoin/core/txhistory.py +++ b/src/cutecoin/core/txhistory.py @@ -85,13 +85,13 @@ class TxHistory(): receivers = [txdata['issuers'][0]] try: - issuer = yield from self.wallet._identities_registry.future_lookup(txdata['issuers'][0], community) + issuer = yield from self.wallet._identities_registry.future_find(txdata['issuers'][0], community) issuer_uid = issuer.uid except LookupFailureError: issuer_uid = "" try: - receiver = yield from self.wallet._identities_registry.future_lookup(receivers[0], community) + receiver = yield from self.wallet._identities_registry.future_find(receivers[0], community) receiver_uid = receiver.uid except LookupFailureError: receiver_uid = "" diff --git a/src/cutecoin/core/wallet.py b/src/cutecoin/core/wallet.py index 751d9099..25cdba27 100644 --- a/src/cutecoin/core/wallet.py +++ b/src/cutecoin/core/wallet.py @@ -247,13 +247,13 @@ class Wallet(QObject): logging.debug("Sender pubkey:{0}".format(key.pubkey)) try: - issuer = yield from self._identities_registry.future_lookup(key.pubkey, community) + issuer = yield from self._identities_registry.future_find(key.pubkey, community) issuer_uid = issuer.uid except LookupFailureError as e: issuer_uid = "" try: - receiver = yield from self._identities_registry.future_lookup(recipient, community) + receiver = yield from self._identities_registry.future_find(recipient, community) receiver_uid = receiver.uid except LookupFailureError as e: receiver_uid = "" diff --git a/src/cutecoin/gui/community_tab.py b/src/cutecoin/gui/community_tab.py index 38caf285..6c11dc6e 100644 --- a/src/cutecoin/gui/community_tab.py +++ b/src/cutecoin/gui/community_tab.py @@ -189,7 +189,7 @@ class CommunityTabWidget(QWidget, Ui_CommunityTabWidget): response = yield from self.community.bma_access.future_request(qtbma.wot.Lookup, {'search': text}) identities = [] for identity_data in response['results']: - identity = yield from self.app.identities_registry.future_lookup(identity_data['pubkey'], self.community) + identity = yield from self.app.identities_registry.future_find(identity_data['pubkey'], self.community) identities.append(identity) self_identity = self.account.identity(self.community) diff --git a/src/cutecoin/gui/process_cfg_community.py b/src/cutecoin/gui/process_cfg_community.py index 993b6e57..9f37d5ed 100644 --- a/src/cutecoin/gui/process_cfg_community.py +++ b/src/cutecoin/gui/process_cfg_community.py @@ -225,7 +225,7 @@ class ProcessConfigureCommunity(QDialog, Ui_CommunityConfigurationDialog): @asyncio.coroutine def final(self): - identity = yield from self.app.identities_registry.future_lookup(self.account.pubkey, self.community) + identity = yield from self.app.identities_registry.future_find(self.account.pubkey, self.community) if identity.status == Identity.NOT_FOUND: reply = QMessageBox.question(self, self.tr("Pubkey not found"), self.tr("""The public key of your account wasn't found in the community. :\n diff --git a/src/cutecoin/tests/stubs/core/registry/identities.py b/src/cutecoin/tests/stubs/core/registry/identities.py index e06ecb44..7cebf652 100644 --- a/src/cutecoin/tests/stubs/core/registry/identities.py +++ b/src/cutecoin/tests/stubs/core/registry/identities.py @@ -20,7 +20,7 @@ class IdentitiesRegistry: return identity @asyncio.coroutine - def future_lookup(self, pubkey, community): + def future_find(self, pubkey, community): identity = Identity.empty(pubkey) yield from asyncio.sleep(1) return identity -- GitLab