Skip to content

Commit

Permalink
Remove stale PeerIDs in hivemind-dht's routing table (#525)
Browse files Browse the repository at this point in the history
Before this PR, hivemind-dht-based initial peers collected lots of stale PeerIDs and other peers could not actually make DHT queries anymore.
  • Loading branch information
borzunov authored Nov 29, 2022
1 parent 1e4af43 commit be88b42
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions hivemind/hivemind_cli/run_dht.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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()
Expand Down

0 comments on commit be88b42

Please sign in to comment.