update network to scan fast even if some miners are not responding properly
This commit is contained in:
@@ -87,7 +87,7 @@ class MinerNetwork:
|
|||||||
for host in local_network.hosts():
|
for host in local_network.hosts():
|
||||||
|
|
||||||
# make sure we don't exceed the allowed async tasks
|
# make sure we don't exceed the allowed async tasks
|
||||||
if len(scan_tasks) < PyasicSettings().network_scan_threads:
|
if len(scan_tasks) < round(PyasicSettings().network_scan_threads / 3):
|
||||||
# add the task to the list
|
# add the task to the list
|
||||||
scan_tasks.append(self.ping_and_get_miner(host))
|
scan_tasks.append(self.ping_and_get_miner(host))
|
||||||
else:
|
else:
|
||||||
@@ -126,7 +126,7 @@ class MinerNetwork:
|
|||||||
# for each ip on the network, loop through and scan it
|
# for each ip on the network, loop through and scan it
|
||||||
for host in local_network.hosts():
|
for host in local_network.hosts():
|
||||||
# make sure we don't exceed the allowed async tasks
|
# make sure we don't exceed the allowed async tasks
|
||||||
if len(scan_tasks) >= PyasicSettings().network_scan_threads:
|
if len(scan_tasks) >= round(PyasicSettings().network_scan_threads / 3):
|
||||||
# scanned is a loopable list of awaitables
|
# scanned is a loopable list of awaitables
|
||||||
scanned = asyncio.as_completed(scan_tasks)
|
scanned = asyncio.as_completed(scan_tasks)
|
||||||
# when we scan, empty the scan tasks
|
# when we scan, empty the scan tasks
|
||||||
@@ -146,31 +146,21 @@ class MinerNetwork:
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
async def ping_miner(ip: ipaddress.ip_address) -> None or ipaddress.ip_address:
|
async def ping_miner(ip: ipaddress.ip_address) -> None or ipaddress.ip_address:
|
||||||
miner = await ping_miner(ip)
|
tasks = [ping_miner(ip, port=port) for port in [4028, 4029, 8889]]
|
||||||
|
for miner in asyncio.as_completed(tasks):
|
||||||
|
miner = await miner
|
||||||
if miner:
|
if miner:
|
||||||
return miner
|
return miner
|
||||||
miner = await ping_miner(ip, port=4029)
|
|
||||||
if miner:
|
|
||||||
return miner
|
|
||||||
miner = await ping_miner(ip, port=8889)
|
|
||||||
if miner:
|
|
||||||
return miner
|
|
||||||
return None
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
async def ping_and_get_miner(
|
async def ping_and_get_miner(
|
||||||
ip: ipaddress.ip_address,
|
ip: ipaddress.ip_address,
|
||||||
) -> None or AnyMiner:
|
) -> None or AnyMiner:
|
||||||
miner = await ping_and_get_miner(ip)
|
tasks = [ping_and_get_miner(ip, port=port) for port in [4028, 4029, 8889]]
|
||||||
|
for miner in asyncio.as_completed(tasks):
|
||||||
|
miner = await miner
|
||||||
if miner:
|
if miner:
|
||||||
return miner
|
return miner
|
||||||
miner = await ping_and_get_miner(ip, port=4029)
|
|
||||||
if miner:
|
|
||||||
return miner
|
|
||||||
miner = await ping_and_get_miner(ip, port=8889)
|
|
||||||
if miner:
|
|
||||||
return miner
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
async def ping_miner(
|
async def ping_miner(
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ class Singleton(type):
|
|||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class PyasicSettings(metaclass=Singleton):
|
class PyasicSettings(metaclass=Singleton):
|
||||||
network_ping_retries: int = 3
|
network_ping_retries: int = 1
|
||||||
network_ping_timeout: int = 5
|
network_ping_timeout: int = 3
|
||||||
network_scan_threads: int = 300
|
network_scan_threads: int = 300
|
||||||
|
|
||||||
miner_factory_get_version_retries: int = 1
|
miner_factory_get_version_retries: int = 1
|
||||||
|
|||||||
Reference in New Issue
Block a user