From d56da007a53c3a9f0f8b276770e916c1181b624e Mon Sep 17 00:00:00 2001 From: Upstream Data Date: Fri, 12 Apr 2024 13:40:10 -0600 Subject: [PATCH] feature: make mara discover more consistent. --- pyasic/miners/backends/marathon.py | 4 ++-- pyasic/miners/factory.py | 13 +++++++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/pyasic/miners/backends/marathon.py b/pyasic/miners/backends/marathon.py index 8b4e2a16..50960310 100644 --- a/pyasic/miners/backends/marathon.py +++ b/pyasic/miners/backends/marathon.py @@ -163,7 +163,7 @@ class MaraMiner(BaseMiner): if web_overview is not None: try: - return web_overview["version_firmware"].upper() + return web_overview["version_firmware"] except LookupError: pass @@ -176,7 +176,7 @@ class MaraMiner(BaseMiner): if web_network_config is not None: try: - return web_network_config["hostname"].upper() + return web_network_config["hostname"] except LookupError: pass diff --git a/pyasic/miners/factory.py b/pyasic/miners/factory.py index 3f34ff6b..15e6c02a 100644 --- a/pyasic/miners/factory.py +++ b/pyasic/miners/factory.py @@ -533,7 +533,7 @@ class MinerFactory: async def _get_miner_type(self, ip: str) -> MinerTypes | None: tasks = [ asyncio.create_task(self._get_miner_web(ip)), - asyncio.create_task(self._get_miner_socket(ip)), + # asyncio.create_task(self._get_miner_socket(ip)), ] return await concurrent_get_first_result(tasks, lambda x: x is not None) @@ -555,7 +555,16 @@ class MinerFactory: and self._parse_web_type(x[0], x[1]) is not None, ) if text is not None: - return self._parse_web_type(text, resp) + mtype = self._parse_web_type(text, resp) + if mtype == MinerTypes.ANTMINER: + # could still be mara + auth = httpx.DigestAuth("root", "root") + res = await self.send_web_command( + ip, "/kaonsu/v1/brief", auth=auth + ) + if res is not None: + mtype = MinerTypes.MARATHON + return mtype except asyncio.CancelledError: for t in tasks: t.cancel()