mirror of
https://github.com/Chia-Network/chia-blockchain.git
synced 2024-09-11 10:56:14 +03:00
Listen on ::0 so we can respond to both ipv4 and ipv6 (#14731)
* Listen on ::0 so we can respond to both ipv4 and ipv6 * Move the initial sleep to the end of the first attempt to load reliable peers, so that if we already have a database, it doesn't take 60 seconds to start responding
This commit is contained in:
parent
69a91d24ef
commit
db6bf72af3
@ -93,15 +93,13 @@ class DNSServer:
|
||||
# One protocol instance will be created to serve all
|
||||
# client requests.
|
||||
self.transport, self.protocol = await loop.create_datagram_endpoint(
|
||||
lambda: EchoServerProtocol(self.dns_response), local_addr=("0.0.0.0", 53)
|
||||
lambda: EchoServerProtocol(self.dns_response), local_addr=("::0", 53)
|
||||
)
|
||||
self.reliable_task = asyncio.create_task(self.periodically_get_reliable_peers())
|
||||
|
||||
async def periodically_get_reliable_peers(self):
|
||||
sleep_interval = 0
|
||||
while True:
|
||||
sleep_interval = min(15, sleep_interval + 1)
|
||||
await asyncio.sleep(sleep_interval * 60)
|
||||
try:
|
||||
# TODO: double check this. It shouldn't take this long to connect.
|
||||
crawl_db = await aiosqlite.connect(self.db_path, timeout=600)
|
||||
@ -143,6 +141,9 @@ class DNSServer:
|
||||
except Exception as e:
|
||||
log.error(f"Exception: {e}. Traceback: {traceback.format_exc()}.")
|
||||
|
||||
sleep_interval = min(15, sleep_interval + 1)
|
||||
await asyncio.sleep(sleep_interval * 60)
|
||||
|
||||
async def get_peers_to_respond(self, ipv4_count, ipv6_count):
|
||||
peers = []
|
||||
async with self.lock:
|
||||
|
Loading…
Reference in New Issue
Block a user