Skip to content

Commit

Permalink
Fasten up a little the wot graph
Browse files Browse the repository at this point in the history
  • Loading branch information
Insoleet committed Jan 29, 2016
1 parent 8f7c9d4 commit 9ea7c38
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
13 changes: 8 additions & 5 deletions src/sakia/core/graph/explorer_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,17 @@ async def _explore(self, identity, steps):
logging.debug("New identity explored : {pubkey}".format(pubkey=current_identity.pubkey[:5]))
self.graph_changed.emit()

certifier_list = await current_identity.unique_valid_certifiers_of(self.app.identities_registry,
self.community)
certifier_coro = asyncio.ensure_future(current_identity.unique_valid_certifiers_of(self.app.identities_registry,
self.community))

certified_coro = asyncio.ensure_future(current_identity.unique_valid_certified_by(self.app.identities_registry,
self.community))

certifier_list, certified_list = await asyncio.gather(certifier_coro, certified_coro)

await self.add_certifier_list(certifier_list, current_identity, identity)
logging.debug("New identity certifiers : {pubkey}".format(pubkey=current_identity.pubkey[:5]))
self.graph_changed.emit()

certified_list = await current_identity.unique_valid_certified_by(self.app.identities_registry,
self.community)
await self.add_certified_list(certified_list, current_identity, identity)
logging.debug("New identity certified : {pubkey}".format(pubkey=current_identity.pubkey[:5]))
self.graph_changed.emit()
Expand Down
15 changes: 10 additions & 5 deletions src/sakia/core/graph/wot_graph.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
import asyncio
import networkx
from .base_graph import BaseGraph
from .constants import NodeStatus
Expand Down Expand Up @@ -65,14 +66,17 @@ async def explore_to_find_member(self, account_identity, to_identity):

while len(explorable) > 0:
current = explorable.pop()
certifier_list = await current.unique_valid_certifiers_of(self.app.identities_registry,
self.community)
certifier_coro = asyncio.ensure_future(current.unique_valid_certifiers_of(self.app.identities_registry,
self.community))
certified_coro = asyncio.ensure_future(current.unique_valid_certified_by(self.app.identities_registry,
self.community))

certifier_list, certified_list = await asyncio.gather(certifier_coro, certified_coro)

await self.add_certifier_list(certifier_list, current, account_identity)
if to_identity.pubkey in [data['identity'].pubkey for data in certifier_list]:
return True

certified_list = await current.unique_valid_certified_by(self.app.identities_registry,
self.community)
await self.add_certified_list(certified_list, current, account_identity)
if to_identity.pubkey in [data['identity'].pubkey for data in certified_list]:
return True
Expand All @@ -81,4 +85,5 @@ async def explore_to_find_member(self, account_identity, to_identity):
for entry in certifier_list + certified_list:
if entry['identity'] not in explored + explorable:
explorable.append(entry['identity'])
return False

return False

0 comments on commit 9ea7c38

Please sign in to comment.