From 9ea7c38da930a6924bf249e5e63cd97b1ed2f991 Mon Sep 17 00:00:00 2001 From: Inso Date: Fri, 29 Jan 2016 22:19:31 +0100 Subject: [PATCH] Fasten up a little the wot graph --- src/sakia/core/graph/explorer_graph.py | 13 ++++++++----- src/sakia/core/graph/wot_graph.py | 15 ++++++++++----- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/sakia/core/graph/explorer_graph.py b/src/sakia/core/graph/explorer_graph.py index 420b4b48..a698e464 100644 --- a/src/sakia/core/graph/explorer_graph.py +++ b/src/sakia/core/graph/explorer_graph.py @@ -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() diff --git a/src/sakia/core/graph/wot_graph.py b/src/sakia/core/graph/wot_graph.py index 196c0f91..b80a6979 100644 --- a/src/sakia/core/graph/wot_graph.py +++ b/src/sakia/core/graph/wot_graph.py @@ -1,4 +1,5 @@ import logging +import asyncio import networkx from .base_graph import BaseGraph from .constants import NodeStatus @@ -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 @@ -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 \ No newline at end of file + + return False