Skip to content

Commit be88b42

Browse files
authored
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.
1 parent 1e4af43 commit be88b42

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

hivemind/hivemind_cli/run_dht.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import time
22
from argparse import ArgumentParser
3+
from secrets import token_hex
34

45
from hivemind.dht import DHT, DHTNode
56
from hivemind.utils.logging import get_logger, use_hivemind_log_handler
@@ -18,6 +19,9 @@ async def report_status(dht: DHT, node: DHTNode):
1819
logger.info(f"Local storage contains {len(node.protocol.storage)} keys")
1920
logger.debug(f"Local storage contents: {node.protocol.storage}")
2021

22+
# Contact peers and keep the routing table healthy (remove stale PeerIDs)
23+
await node.get(f"heartbeat_{token_hex(16)}", latest=True)
24+
2125

2226
def main():
2327
parser = ArgumentParser()

0 commit comments

Comments
 (0)