Skip to content
Snippets Groups Projects
Commit a8e130af authored by inso's avatar inso
Browse files

Replacing future_lookup with future_find #178

parent 8a8a3dd6
No related branches found
No related tags found
No related merge requests found
...@@ -442,7 +442,7 @@ class Account(QObject): ...@@ -442,7 +442,7 @@ class Account(QObject):
logging.debug("Send membership") logging.debug("Send membership")
blockid = yield from community.blockid() 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) selfcert = yield from self_identity.selfcert(community)
membership = Membership(PROTOCOL_VERSION, community.currency, membership = Membership(PROTOCOL_VERSION, community.currency,
...@@ -495,7 +495,7 @@ class Account(QObject): ...@@ -495,7 +495,7 @@ class Account(QObject):
""" """
logging.debug("Certdata") logging.debug("Certdata")
blockid = yield from community.blockid() 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) selfcert = yield from identity.selfcert(community)
certification = Certification(PROTOCOL_VERSION, community.currency, certification = Certification(PROTOCOL_VERSION, community.currency,
self.pubkey, pubkey, self.pubkey, pubkey,
...@@ -549,7 +549,7 @@ class Account(QObject): ...@@ -549,7 +549,7 @@ class Account(QObject):
:param str password: The account SigningKey password :param str password: The account SigningKey password
:param cutecoin.core.community.Community community: The community target of the revocation :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) revocation = Revocation(PROTOCOL_VERSION, community.currency, None)
selfcert = revoked.selfcert(community) selfcert = revoked.selfcert(community)
......
...@@ -13,10 +13,10 @@ PROTOCOL_VERSION = "1" ...@@ -13,10 +13,10 @@ PROTOCOL_VERSION = "1"
@asyncio.coroutine @asyncio.coroutine
def timeout(reply, seconds): def timeout(reply, seconds):
logging.debug("Sleep timeout...") #logging.debug("Sleep timeout...")
yield from asyncio.sleep(seconds) yield from asyncio.sleep(seconds)
if reply.isRunning(): if reply.isRunning():
logging.debug("Reply aborted because of timeout") #logging.debug("Reply aborted because of timeout")
reply.abort() reply.abort()
......
...@@ -87,7 +87,7 @@ class IdentitiesRegistry: ...@@ -87,7 +87,7 @@ class IdentitiesRegistry:
reply = community.bma_access.simple_request(qtbma.wot.CertifiersOf, req_args={'search': pubkey}) reply = community.bma_access.simple_request(qtbma.wot.CertifiersOf, req_args={'search': pubkey})
reply.finished.connect(lambda: handle_certifiersof_reply(reply, tries=tries+1)) reply.finished.connect(lambda: handle_certifiersof_reply(reply, tries=tries+1))
else: else:
future_identity.set_result(False) future_identity.set_result(True)
def handle_lookup_reply(reply, tries=0): def handle_lookup_reply(reply, tries=0):
status_code = reply.attribute(QNetworkRequest.HttpStatusCodeAttribute) status_code = reply.attribute(QNetworkRequest.HttpStatusCodeAttribute)
...@@ -114,7 +114,7 @@ class IdentitiesRegistry: ...@@ -114,7 +114,7 @@ class IdentitiesRegistry:
reply = community.bma_access.simple_request(qtbma.wot.Lookup, req_args={'search': pubkey}) reply = community.bma_access.simple_request(qtbma.wot.Lookup, req_args={'search': pubkey})
reply.finished.connect(lambda: handle_lookup_reply(reply, tries=tries+1)) reply.finished.connect(lambda: handle_lookup_reply(reply, tries=tries+1))
else: else:
future_identity.set_result(False) future_identity.set_result(True)
future_identity = asyncio.Future() future_identity = asyncio.Future()
if pubkey in self._instances: if pubkey in self._instances:
......
...@@ -85,13 +85,13 @@ class TxHistory(): ...@@ -85,13 +85,13 @@ class TxHistory():
receivers = [txdata['issuers'][0]] receivers = [txdata['issuers'][0]]
try: 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 issuer_uid = issuer.uid
except LookupFailureError: except LookupFailureError:
issuer_uid = "" issuer_uid = ""
try: 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 receiver_uid = receiver.uid
except LookupFailureError: except LookupFailureError:
receiver_uid = "" receiver_uid = ""
......
...@@ -247,13 +247,13 @@ class Wallet(QObject): ...@@ -247,13 +247,13 @@ class Wallet(QObject):
logging.debug("Sender pubkey:{0}".format(key.pubkey)) logging.debug("Sender pubkey:{0}".format(key.pubkey))
try: 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 issuer_uid = issuer.uid
except LookupFailureError as e: except LookupFailureError as e:
issuer_uid = "" issuer_uid = ""
try: 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 receiver_uid = receiver.uid
except LookupFailureError as e: except LookupFailureError as e:
receiver_uid = "" receiver_uid = ""
......
...@@ -189,7 +189,7 @@ class CommunityTabWidget(QWidget, Ui_CommunityTabWidget): ...@@ -189,7 +189,7 @@ class CommunityTabWidget(QWidget, Ui_CommunityTabWidget):
response = yield from self.community.bma_access.future_request(qtbma.wot.Lookup, {'search': text}) response = yield from self.community.bma_access.future_request(qtbma.wot.Lookup, {'search': text})
identities = [] identities = []
for identity_data in response['results']: 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) identities.append(identity)
self_identity = self.account.identity(self.community) self_identity = self.account.identity(self.community)
......
...@@ -225,7 +225,7 @@ class ProcessConfigureCommunity(QDialog, Ui_CommunityConfigurationDialog): ...@@ -225,7 +225,7 @@ class ProcessConfigureCommunity(QDialog, Ui_CommunityConfigurationDialog):
@asyncio.coroutine @asyncio.coroutine
def final(self): 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: if identity.status == Identity.NOT_FOUND:
reply = QMessageBox.question(self, self.tr("Pubkey 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 self.tr("""The public key of your account wasn't found in the community. :\n
......
...@@ -20,7 +20,7 @@ class IdentitiesRegistry: ...@@ -20,7 +20,7 @@ class IdentitiesRegistry:
return identity return identity
@asyncio.coroutine @asyncio.coroutine
def future_lookup(self, pubkey, community): def future_find(self, pubkey, community):
identity = Identity.empty(pubkey) identity = Identity.empty(pubkey)
yield from asyncio.sleep(1) yield from asyncio.sleep(1)
return identity return identity
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment