Compare commits

...

4 Commits

Author SHA1 Message Date
UpstreamData
29aeea1194 bump version number 2022-07-19 13:02:55 -06:00
UpstreamData
994d53ae3b removed arbitrary scan thread limitation dividing 2022-07-19 13:01:39 -06:00
UpstreamData
a95333eb1c removed arbitrary scan thread limitation dividing 2022-07-19 13:01:28 -06:00
UpstreamData
c5f2d71791 improved the speed of scanning by only checking secondary ports if the 4028 connection is refused 2022-07-19 13:00:15 -06:00
2 changed files with 27 additions and 9 deletions

View File

@@ -97,7 +97,7 @@ class MinerNetwork:
for host in local_network.hosts():
# make sure we don't exceed the allowed async tasks
if len(scan_tasks) < round(PyasicSettings().network_scan_threads / 3):
if len(scan_tasks) < round(PyasicSettings().network_scan_threads):
# add the task to the list
scan_tasks.append(self.ping_and_get_miner(host))
else:
@@ -137,7 +137,7 @@ class MinerNetwork:
# for each ip on the network, loop through and scan it
for host in local_network.hosts():
# make sure we don't exceed the allowed async tasks
if len(scan_tasks) >= round(PyasicSettings().network_scan_threads / 3):
if len(scan_tasks) >= round(PyasicSettings().network_scan_threads):
# scanned is a loopable list of awaitables
scanned = asyncio.as_completed(scan_tasks)
# when we scan, empty the scan tasks
@@ -157,21 +157,37 @@ class MinerNetwork:
@staticmethod
async def ping_miner(ip: ipaddress.ip_address) -> Union[None, ipaddress.ip_address]:
tasks = [ping_miner(ip, port=port) for port in [4028, 4029, 8889]]
for miner in asyncio.as_completed(tasks):
miner = await miner
try:
miner = await ping_miner(ip)
if miner:
return miner
except ConnectionRefusedError:
tasks = [ping_miner(ip, port=port) for port in [4029, 8889]]
for miner in asyncio.as_completed(tasks):
try:
miner = await miner
if miner:
return miner
except ConnectionRefusedError:
pass
@staticmethod
async def ping_and_get_miner(
ip: ipaddress.ip_address,
) -> Union[None, AnyMiner]:
tasks = [ping_and_get_miner(ip, port=port) for port in [4028, 4029, 8889]]
for miner in asyncio.as_completed(tasks):
miner = await miner
try:
miner = await ping_and_get_miner(ip)
if miner:
return miner
except ConnectionRefusedError:
tasks = [ping_and_get_miner(ip, port=port) for port in [4029, 8889]]
for miner in asyncio.as_completed(tasks):
try:
miner = await miner
if miner:
return miner
except ConnectionRefusedError:
pass
async def ping_miner(
@@ -196,6 +212,7 @@ async def ping_miner(
except ConnectionRefusedError:
# handle for other connection errors
logging.debug(f"{str(ip)}: Connection Refused.")
raise ConnectionRefusedError
# ping failed, likely with an exception
except Exception as e:
logging.warning(f"{str(ip)}: {e}")
@@ -225,6 +242,7 @@ async def ping_and_get_miner(
except ConnectionRefusedError:
# handle for other connection errors
logging.debug(f"{str(ip)}: Connection Refused.")
raise ConnectionRefusedError
# ping failed, likely with an exception
except Exception as e:
logging.warning(f"{str(ip)}: {e}")

View File

@@ -1,6 +1,6 @@
[tool.poetry]
name = "pyasic"
version = "0.12.4"
version = "0.12.5"
description = "A set of modules for interfacing with many common types of ASIC bitcoin miners, using both their API and SSH."
authors = ["UpstreamData <brett@upstreamdata.ca>"]
repository = "https://github.com/UpstreamData/pyasic"