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

Fix crash when recursively looking for a key fails

parent d485af08
No related branches found
No related tags found
No related merge requests found
...@@ -85,7 +85,7 @@ class Graph(object): ...@@ -85,7 +85,7 @@ class Graph(object):
# recursively feed graph searching for account node... # recursively feed graph searching for account node...
yield from self.explore_to_find_member(to_identity, yield from self.explore_to_find_member(to_identity,
self._graph[from_identity.pubkey]['connected'], list()) self._graph[from_identity.pubkey]['connected'], list())
if len(self._graph[from_identity.pubkey]['connected']) > 0: if len(self._graph[from_identity.pubkey]['connected']) > 0 and to_identity.pubkey in self._graph:
# calculate path of nodes between identity and to_identity # calculate path of nodes between identity and to_identity
path = yield from self.find_shortest_path(self._graph[from_identity.pubkey], path = yield from self.find_shortest_path(self._graph[from_identity.pubkey],
self._graph[to_identity.pubkey]) self._graph[to_identity.pubkey])
...@@ -105,7 +105,7 @@ class Graph(object): ...@@ -105,7 +105,7 @@ class Graph(object):
:param list connected: Optional, default=None, Pubkey list of the connected nodes :param list connected: Optional, default=None, Pubkey list of the connected nodes
around the current scanned node around the current scanned node
:param list done: Optional, default=None, List of node already scanned :param list done: Optional, default=None, List of node already scanned
:return: :return: False when the identity is added in the graph
""" """
# functions keywords args are persistent... Need to reset it with None trick # functions keywords args are persistent... Need to reset it with None trick
connected = connected or (list() and (connected is None)) connected = connected or (list() and (connected is None))
...@@ -123,23 +123,23 @@ class Graph(object): ...@@ -123,23 +123,23 @@ class Graph(object):
self.community) self.community)
yield from self.add_certifier_list(certifier_list, identity_selected, identity) yield from self.add_certifier_list(certifier_list, identity_selected, identity)
if identity.pubkey in tuple(self._graph.keys()): if identity.pubkey in tuple(self._graph.keys()):
return False return True
certified_list = yield from identity_selected.unique_valid_certified_by(self.app.identities_registry, certified_list = yield from identity_selected.unique_valid_certified_by(self.app.identities_registry,
self.community) self.community)
yield from self.add_certified_list(certified_list, identity_selected, identity) yield from self.add_certified_list(certified_list, identity_selected, identity)
if identity.pubkey in tuple(self._graph.keys()): if identity.pubkey in tuple(self._graph.keys()):
return False return True
if node['id'] not in tuple(done): if node['id'] not in tuple(done):
done.append(node['id']) done.append(node['id'])
if len(done) >= len(self._graph): if len(done) >= len(self._graph):
return True return False
result = yield from self.explore_to_find_member(identity, found = yield from self.explore_to_find_member(identity,
self._graph[identity_selected.pubkey]['connected'], self._graph[identity_selected.pubkey]['connected'],
done) done)
if not result: if found:
return False return True
return True return False
@asyncio.coroutine @asyncio.coroutine
def find_shortest_path(self, start, end, path=None): def find_shortest_path(self, start, end, path=None):
......
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