fix a bug with X17 not responding

This commit is contained in:
UpstreamData
2022-05-25 08:56:02 -06:00
parent 726e7ff0f0
commit 149c386a4c

View File

@@ -273,10 +273,12 @@ class MinerFactory(metaclass=Singleton):
async def _get_miner_type(self, ip: ipaddress.ip_address or str) -> tuple: async def _get_miner_type(self, ip: ipaddress.ip_address or str) -> tuple:
model = None model = None
api = None api = None
data = None
devdetails = None devdetails = None
version = None version = None
for i in range(GET_VERSION_RETRIES):
try: try:
data = await self._send_api_command(str(ip), "devdetails+version") data = await self._send_api_command(str(ip), "devdetails+version")
@@ -290,6 +292,9 @@ class MinerFactory(metaclass=Singleton):
except APIError as e: except APIError as e:
data = None data = None
if data:
break
if not data: if not data:
try: try:
devdetails = await self._send_api_command(str(ip), "devdetails") devdetails = await self._send_api_command(str(ip), "devdetails")
@@ -308,6 +313,9 @@ class MinerFactory(metaclass=Singleton):
logging.warning(f"{ip}: API Command Error: {e}") logging.warning(f"{ip}: API Command Error: {e}")
return None, None return None, None
print(version)
print(devdetails)
if devdetails: if devdetails:
if "DEVDETAILS" in devdetails.keys() and not devdetails["DEVDETAILS"] == []: if "DEVDETAILS" in devdetails.keys() and not devdetails["DEVDETAILS"] == []:
# check for model, for most miners # check for model, for most miners
@@ -348,17 +356,20 @@ class MinerFactory(metaclass=Singleton):
api = "BOSMiner+" api = "BOSMiner+"
# if all that fails, check the Description to see if it is a whatsminer # if all that fails, check the Description to see if it is a whatsminer
if version.get("Description") and "whatsminer" in version.get( if version.get("Description") and "whatsminer" in version.get("Description"):
"Description"
):
api = "BTMiner" api = "BTMiner"
if version and not model: if version and not model:
if ( if (
"VERSION" in version.keys() "VERSION" in version.keys()
and version.get("VERSION") and version.get("VERSION")
and not version.get("VERSION") == [] and not version.get("VERSION") == []
): ):
if version["VERSION"][0].get("Type"):
model = version["VERSION"][0]["Type"] model = version["VERSION"][0]["Type"]
elif "am2-s17" in version["STATUS"][0]["Description"]:
model = "Antminer S17"
if model: if model:
if "V" in model: if "V" in model: