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

Enhanced UID finding ( bug #232 )

parent 3fc14fe1
No related branches found
No related tags found
No related merge requests found
...@@ -83,7 +83,6 @@ class IdentitiesRegistry: ...@@ -83,7 +83,6 @@ class IdentitiesRegistry:
identity.blockchain_state = BlockchainState.BUFFERED identity.blockchain_state = BlockchainState.BUFFERED
identity.local_state = LocalState.PARTIAL identity.local_state = LocalState.PARTIAL
return identity return identity
logging.debug("Lookup : found {0}".format(identity))
except ValueError as e: except ValueError as e:
lookup_tries += 1 lookup_tries += 1
except asyncio.TimeoutError: except asyncio.TimeoutError:
......
...@@ -244,6 +244,7 @@ class Identity(QObject): ...@@ -244,6 +244,7 @@ class Identity(QObject):
:param cutecoin.core.registry.identities.IdentitiesRegistry identities_registry: The identities registry :param cutecoin.core.registry.identities.IdentitiesRegistry identities_registry: The identities registry
:param cutecoin.core.community.Community community: The community target to request the join date :param cutecoin.core.community.Community community: The community target to request the join date
:return: The list of the certifiers of this community :return: The list of the certifiers of this community
:rtype: list
""" """
certifiers = list() certifiers = list()
try: try:
...@@ -269,6 +270,7 @@ class Identity(QObject): ...@@ -269,6 +270,7 @@ class Identity(QObject):
data = yield from community.bma_access.future_request(bma.wot.Lookup, {'search': self.pubkey}) data = yield from community.bma_access.future_request(bma.wot.Lookup, {'search': self.pubkey})
for result in data['results']: for result in data['results']:
if result["pubkey"] == self.pubkey: if result["pubkey"] == self.pubkey:
self._refresh_uid(result['uids'])
for uid_data in result['uids']: for uid_data in result['uids']:
for certifier_data in uid_data['others']: for certifier_data in uid_data['others']:
for uid in certifier_data['uids']: for uid in certifier_data['uids']:
...@@ -322,6 +324,7 @@ class Identity(QObject): ...@@ -322,6 +324,7 @@ class Identity(QObject):
:param cutecoin.core.community.Community community: The community target to request the join date :param cutecoin.core.community.Community community: The community target to request the join date
:return: The list of the certified persons of this community in BMA json format :return: The list of the certified persons of this community in BMA json format
:rtype: list
""" """
certified_list = list() certified_list = list()
try: try:
...@@ -345,6 +348,7 @@ class Identity(QObject): ...@@ -345,6 +348,7 @@ class Identity(QObject):
data = yield from community.bma_access.future_request(bma.wot.Lookup, {'search': self.pubkey}) data = yield from community.bma_access.future_request(bma.wot.Lookup, {'search': self.pubkey})
for result in data['results']: for result in data['results']:
if result["pubkey"] == self.pubkey: if result["pubkey"] == self.pubkey:
self._refresh_uid(result['uids'])
for certified_data in result['signed']: for certified_data in result['signed']:
certified = {} certified = {}
certified['identity'] = identities_registry.from_handled_data(certified_data['uid'], certified['identity'] = identities_registry.from_handled_data(certified_data['uid'],
...@@ -394,6 +398,20 @@ class Identity(QObject): ...@@ -394,6 +398,20 @@ class Identity(QObject):
current_time = time.time() current_time = time.time()
return expiration_date - current_time return expiration_date - current_time
def _refresh_uid(self, uids):
"""
Refresh UID from uids list, got from a successful lookup request
:param list uids: UIDs got from a lookup request
"""
if self.local_state == LocalState.NOT_FOUND:
for uid_data in uids:
if uid_data["meta"]["timestamp"] > timestamp:
timestamp = uid_data["meta"]["timestamp"]
identity_uid = uid_data["uid"]
self.uid = identity_uid
self.blockchain_state = BlockchainState.BUFFERED
self.local_state = LocalState.PARTIAL
def jsonify(self): def jsonify(self):
""" """
Get the community as dict in json format. Get the community as dict in json format.
......
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