Update data locations to be typed with dataclasses and enums. (#82)
* feature: swap AntminerModern to new data location style. * bug: fix a bunch of missed instances of `nominal_` naming. * feature: add support for S19 Pro Hydro. * version: bump version number. * dependencies: bump httpx version * version: bump version number. * feature: implement data locations for all remaining miners. * refactor: remove some unused docstrings. * feature: swap AntminerModern to new data location style. * feature: implement data locations for all remaining miners. * refactor: remove some unused docstrings. * bug: fix misnamed data locations, and update base miner get_data to use new data locations. * bug: fix include/exclude implementation on get_data. * bug: swap ePIC to BaseMiner subclass. * feature: add DataOptions to __all__ * tests: update data tests with new data locations method. * bug: remove bad command from bosminer commands. * dependencies: update dependencies. * bug: fix some typing issues with python 3.8, and remove useless semaphore and scan threads. * bug: fix KeyError when pools rpc command returns broken data.
This commit is contained in:
@@ -123,9 +123,8 @@ class MinerNetwork:
|
||||
# clear cached miners
|
||||
miner_factory.clear_cached_miners()
|
||||
|
||||
limit = asyncio.Semaphore(settings.get("network_scan_threads", 300))
|
||||
miners = await asyncio.gather(
|
||||
*[self.ping_and_get_miner(host, limit) for host in self.hosts]
|
||||
*[self.ping_and_get_miner(host) for host in self.hosts]
|
||||
)
|
||||
|
||||
# remove all None from the miner list
|
||||
@@ -148,12 +147,8 @@ class MinerNetwork:
|
||||
loop = asyncio.get_event_loop()
|
||||
|
||||
# create a list of scan tasks
|
||||
limit = asyncio.Semaphore(settings.get("network_scan_threads", 300))
|
||||
miners = asyncio.as_completed(
|
||||
[
|
||||
loop.create_task(self.ping_and_get_miner(host, limit))
|
||||
for host in self.hosts
|
||||
]
|
||||
[loop.create_task(self.ping_and_get_miner(host)) for host in self.hosts]
|
||||
)
|
||||
for miner in miners:
|
||||
try:
|
||||
@@ -162,21 +157,16 @@ class MinerNetwork:
|
||||
yield None
|
||||
|
||||
@staticmethod
|
||||
async def ping_and_get_miner(
|
||||
ip: ipaddress.ip_address, semaphore: asyncio.Semaphore
|
||||
) -> Union[None, AnyMiner]:
|
||||
async with semaphore:
|
||||
try:
|
||||
return await ping_and_get_miner(ip)
|
||||
except ConnectionRefusedError:
|
||||
tasks = [
|
||||
ping_and_get_miner(ip, port=port) for port in [4028, 4029, 8889]
|
||||
]
|
||||
for miner in asyncio.as_completed(tasks):
|
||||
try:
|
||||
return await miner
|
||||
except ConnectionRefusedError:
|
||||
pass
|
||||
async def ping_and_get_miner(ip: ipaddress.ip_address) -> Union[None, AnyMiner]:
|
||||
try:
|
||||
return await ping_and_get_miner(ip)
|
||||
except ConnectionRefusedError:
|
||||
tasks = [ping_and_get_miner(ip, port=port) for port in [4028, 4029, 8889]]
|
||||
for miner in asyncio.as_completed(tasks):
|
||||
try:
|
||||
return await miner
|
||||
except ConnectionRefusedError:
|
||||
pass
|
||||
|
||||
|
||||
async def ping_and_get_miner(
|
||||
|
||||
Reference in New Issue
Block a user