Skip to content

Commit

Permalink
Query random key to collect more DHT neighbors
Browse files Browse the repository at this point in the history
  • Loading branch information
borzunov committed Jan 12, 2023
1 parent 17dcbbb commit 378b78b
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/petals/server/reachability.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import time
from contextlib import asynccontextmanager
from functools import partial
from secrets import token_hex
from typing import Optional

import requests
Expand Down Expand Up @@ -56,6 +57,9 @@ def check_direct_reachability(max_peers: int = 5, threshold: float = 0.5, **kwar

async def _check_direct_reachability():
target_dht = await DHTNode.create(client_mode=True, **kwargs)
await target_dht.get(f"fake_{token_hex(16)}", latest=True) # Query random key to collect more DHT neighbors
logger.debug(f"DHT neighbor count: {len(target_dht.protocol.routing_table.peer_id_to_uid)}")

try:
protocol = ReachabilityProtocol(target_dht.protocol.p2p)
async with protocol.serve():
Expand Down

0 comments on commit 378b78b

Please sign in to comment.