Skip to content

Commit

Permalink
make find node code more elegant
Browse files Browse the repository at this point in the history
  • Loading branch information
amirongit committed Oct 15, 2024
1 parent 75c9d11 commit f767d5a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/use_case/find_node.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from copy import deepcopy

from src.abc.infra.inode_client import INodeClient
from src.abc.infra.inode_repo import INodeRepo
from src.abc.use_case.find_node_use_case import FindNodeUseCase
Expand All @@ -23,7 +25,7 @@ async def execute(self, identifier: NodeIdentifier, questioners: set[NodeIdentif
try:
return await self._node_repo.get(identifier)
except DoesNotExist:
new_questioners = questioners | {self._settings.IDENTIFIER}
(new_questioners := deepcopy(questioners)).add(self._settings.IDENTIFIER)
for node in filter(lambda n: n.identifier not in new_questioners, await self._node_repo.all()):
try:
return await self._node_client.find_node(node, new_questioners, identifier)
Expand Down

0 comments on commit f767d5a

Please sign in to comment.