소스 검색

Merge pull request #543 from exo-explore/topofix

Topofix
Alex Cheema 5 달 전
부모
커밋
f58f4e190d
2개의 변경된 파일4개의 추가작업 그리고 2개의 파일을 삭제
  1. 1 1
      exo/orchestration/standard_node.py
  2. 3 1
      exo/topology/topology.py

+ 1 - 1
exo/orchestration/standard_node.py

@@ -410,7 +410,7 @@ class StandardNode(Node):
       try:
       try:
         other_topology = await asyncio.wait_for(peer.collect_topology(visited, max_depth=max_depth - 1), timeout=5.0)
         other_topology = await asyncio.wait_for(peer.collect_topology(visited, max_depth=max_depth - 1), timeout=5.0)
         if DEBUG >= 2: print(f"Collected topology from: {peer.id()}: {other_topology}")
         if DEBUG >= 2: print(f"Collected topology from: {peer.id()}: {other_topology}")
-        next_topology.merge(other_topology)
+        next_topology.merge(peer.id(), other_topology)
       except Exception as e:
       except Exception as e:
         print(f"Error collecting topology from {peer.id()}: {e}")
         print(f"Error collecting topology from {peer.id()}: {e}")
         traceback.print_exc()
         traceback.print_exc()

+ 3 - 1
exo/topology/topology.py

@@ -39,11 +39,13 @@ class Topology:
     conn = PeerConnection(from_id, to_id, description)
     conn = PeerConnection(from_id, to_id, description)
     self.peer_graph[from_id].add(conn)
     self.peer_graph[from_id].add(conn)
 
 
-  def merge(self, other: "Topology"):
+  def merge(self, peer_node_id: str, other: "Topology"):
     for node_id, capabilities in other.nodes.items():
     for node_id, capabilities in other.nodes.items():
+      if node_id != peer_node_id: continue
       self.update_node(node_id, capabilities)
       self.update_node(node_id, capabilities)
     for node_id, connections in other.peer_graph.items():
     for node_id, connections in other.peer_graph.items():
       for conn in connections:
       for conn in connections:
+        if conn.from_id != peer_node_id: continue
         self.add_edge(conn.from_id, conn.to_id, conn.description)
         self.add_edge(conn.from_id, conn.to_id, conn.description)
 
 
   def __str__(self):
   def __str__(self):