Browse Source

Remove stale PeerIDs in hivemind-dht's routing table (#525)

Before this PR, hivemind-dht-based initial peers collected lots of stale PeerIDs and other peers could not actually make DHT queries anymore.

(cherry picked from commit be88b4280cdd87432168e1da238e532f1364078b)
Alexander Borzunov 2 năm trước cách đây
mục cha
commit
bc8629e1ec
1 tập tin đã thay đổi với 4 bổ sung0 xóa
  1. 4 0
      hivemind/hivemind_cli/run_dht.py

+ 4 - 0
hivemind/hivemind_cli/run_dht.py

@@ -1,5 +1,6 @@
 import time
 from argparse import ArgumentParser
+from secrets import token_hex
 
 from hivemind.dht import DHT, DHTNode
 from hivemind.utils.logging import get_logger, use_hivemind_log_handler
@@ -18,6 +19,9 @@ async def report_status(dht: DHT, node: DHTNode):
     logger.info(f"Local storage contains {len(node.protocol.storage)} keys")
     logger.debug(f"Local storage contents: {node.protocol.storage}")
 
+    # Contact peers and keep the routing table healthy (remove stale PeerIDs)
+    await node.get(f"heartbeat_{token_hex(16)}", latest=True)
+
 
 def main():
     parser = ArgumentParser()