From 895a5b7ac82ac329862058a42558603440c7e24a Mon Sep 17 00:00:00 2001 From: UpstreamData Date: Fri, 3 Jun 2022 11:20:34 -0600 Subject: [PATCH] fixed more bugs with whatsminers and added more versions --- logger/__init__.py | 2 +- miners/_backends/btminer.py | 2 +- miners/_types/whatsminer/M2X/M21S.py | 13 +++++++++++-- miners/_types/whatsminer/M2X/__init__.py | 2 +- miners/_types/whatsminer/M3X/M30S.py | 9 +++++++++ miners/_types/whatsminer/M3X/M30S_Plus_Plus.py | 4 ++-- miners/_types/whatsminer/M3X/M31S_Plus.py | 2 +- miners/_types/whatsminer/M3X/__init__.py | 2 +- miners/miner_factory.py | 8 ++++++-- miners/whatsminer/btminer/M2X/M21S.py | 10 ++++++++-- miners/whatsminer/btminer/M2X/__init__.py | 2 +- miners/whatsminer/btminer/M3X/M30S.py | 8 +++++++- miners/whatsminer/btminer/M3X/__init__.py | 2 +- 13 files changed, 50 insertions(+), 16 deletions(-) diff --git a/logger/__init__.py b/logger/__init__.py index f8b07802..3cb97f9d 100644 --- a/logger/__init__.py +++ b/logger/__init__.py @@ -15,7 +15,7 @@ def init_logger(): _logger.setLevel(logging.DEBUG) logging.getLogger("asyncssh").setLevel(logging.DEBUG) else: - _logger.setLevel(logging.INFO) + _logger.setLevel(logging.WARNING) logging.getLogger("asyncssh").setLevel(logging.WARNING) return _logger diff --git a/miners/_backends/btminer.py b/miners/_backends/btminer.py index 6d260152..bd47f4cc 100644 --- a/miners/_backends/btminer.py +++ b/miners/_backends/btminer.py @@ -41,7 +41,7 @@ class BTMiner(BaseMiner): self.hostname = host return self.hostname except APIError: - logging.warning(f"Failed to get hostname for miner: {self}") + logging.info(f"Failed to get hostname for miner: {self}") return "?" except Exception: logging.warning(f"Failed to get hostname for miner: {self}") diff --git a/miners/_types/whatsminer/M2X/M21S.py b/miners/_types/whatsminer/M2X/M21S.py index 5e18fbb7..0cb48217 100644 --- a/miners/_types/whatsminer/M2X/M21S.py +++ b/miners/_types/whatsminer/M2X/M21S.py @@ -1,10 +1,19 @@ from miners import BaseMiner -class M21S(BaseMiner): +class M21SV60(BaseMiner): def __init__(self, ip: str): super().__init__() self.ip = ip - self.model = "M21S" + self.model = "M21S V60" self.nominal_chips = 105 self.fan_count = 2 + + +class M21SV20(BaseMiner): + def __init__(self, ip: str): + super().__init__() + self.ip = ip + self.model = "M21S V20" + self.nominal_chips = 66 + self.fan_count = 2 diff --git a/miners/_types/whatsminer/M2X/__init__.py b/miners/_types/whatsminer/M2X/__init__.py index 46c9aca4..62169f46 100644 --- a/miners/_types/whatsminer/M2X/__init__.py +++ b/miners/_types/whatsminer/M2X/__init__.py @@ -2,5 +2,5 @@ from .M20S import M20S from .M20S_Plus import M20SPlus from .M21 import M21 -from .M21S import M21S +from .M21S import M21SV20, M21SV60 from .M21S_Plus import M21SPlus diff --git a/miners/_types/whatsminer/M3X/M30S.py b/miners/_types/whatsminer/M3X/M30S.py index fa669c14..ee4098b0 100644 --- a/miners/_types/whatsminer/M3X/M30S.py +++ b/miners/_types/whatsminer/M3X/M30S.py @@ -8,3 +8,12 @@ class M30S(BaseMiner): self.model = "M30S" self.nominal_chips = 148 self.fan_count = 2 + + +class M30SV50(BaseMiner): + def __init__(self, ip: str): + super().__init__() + self.ip = ip + self.model = "M30S V50" + self.nominal_chips = 156 + self.fan_count = 2 diff --git a/miners/_types/whatsminer/M3X/M30S_Plus_Plus.py b/miners/_types/whatsminer/M3X/M30S_Plus_Plus.py index ab761e89..c990555d 100644 --- a/miners/_types/whatsminer/M3X/M30S_Plus_Plus.py +++ b/miners/_types/whatsminer/M3X/M30S_Plus_Plus.py @@ -5,7 +5,7 @@ class M30SPlusPlusVG30(BaseMiner): def __init__(self, ip: str): super().__init__() self.ip = ip - self.model = "M30S++V30" + self.model = "M30S++ V30" self.nominal_chips = 111 self.fan_count = 2 @@ -14,6 +14,6 @@ class M30SPlusPlusVG40(BaseMiner): def __init__(self, ip: str): super().__init__() self.ip = ip - self.model = "M30S++V40" + self.model = "M30S++ V40" self.nominal_chips = 117 self.fan_count = 2 diff --git a/miners/_types/whatsminer/M3X/M31S_Plus.py b/miners/_types/whatsminer/M3X/M31S_Plus.py index ef3337a4..cca64dd0 100644 --- a/miners/_types/whatsminer/M3X/M31S_Plus.py +++ b/miners/_types/whatsminer/M3X/M31S_Plus.py @@ -14,6 +14,6 @@ class M31SPlusVE20(BaseMiner): def __init__(self, ip: str): super().__init__() self.ip = ip - self.model = "M31S+VE20" + self.model = "M31S+ VE20" self.nominal_chips = 78 self.fan_count = 2 diff --git a/miners/_types/whatsminer/M3X/__init__.py b/miners/_types/whatsminer/M3X/__init__.py index 51a8fb43..80d643fd 100644 --- a/miners/_types/whatsminer/M3X/__init__.py +++ b/miners/_types/whatsminer/M3X/__init__.py @@ -1,4 +1,4 @@ -from .M30S import M30S +from .M30S import M30S, M30SV50 from .M30S_Plus import M30SPlus from .M30S_Plus_Plus import M30SPlusPlusVG30, M30SPlusPlusVG40 diff --git a/miners/miner_factory.py b/miners/miner_factory.py index ab88a6c2..4aff14f9 100644 --- a/miners/miner_factory.py +++ b/miners/miner_factory.py @@ -133,8 +133,10 @@ MINER_CLASSES = { "BTMiner": BTMinerM21, }, "M21S": { - "Default": BTMinerM21S, - "BTMiner": BTMinerM21S, + "Default": BTMinerM21SV60, + "BTMiner": BTMinerM21SV60, + "60": BTMinerM21SV60, + "20": BTMinerM21SV20, }, "M21S+": { "Default": BTMinerM21SPlus, @@ -143,6 +145,7 @@ MINER_CLASSES = { "M30S": { "Default": BTMinerM30S, "BTMiner": BTMinerM30S, + "50": BTMinerM30SV50, }, "M30S+": { "Default": BTMinerM30SPlus, @@ -433,6 +436,7 @@ class MinerFactory(metaclass=Singleton): if "V" in model: _ver = model.split("V") if len(_ver) > 1: + ver = model.split("V")[1] if "VE" in model: ver = model.split("VE")[1] if "VG" in model: diff --git a/miners/whatsminer/btminer/M2X/M21S.py b/miners/whatsminer/btminer/M2X/M21S.py index 29d9f2c6..0d632f5e 100644 --- a/miners/whatsminer/btminer/M2X/M21S.py +++ b/miners/whatsminer/btminer/M2X/M21S.py @@ -1,8 +1,14 @@ from miners._backends import BTMiner # noqa - Ignore access to _module -from miners._types import M21S # noqa - Ignore access to _module +from miners._types import M21SV20, M21SV60 # noqa - Ignore access to _module -class BTMinerM21S(BTMiner, M21S): +class BTMinerM21SV20(BTMiner, M21SV20): + def __init__(self, ip: str) -> None: + super().__init__(ip) + self.ip = ip + + +class BTMinerM21SV60(BTMiner, M21SV60): def __init__(self, ip: str) -> None: super().__init__(ip) self.ip = ip diff --git a/miners/whatsminer/btminer/M2X/__init__.py b/miners/whatsminer/btminer/M2X/__init__.py index 0203852e..eb25c185 100644 --- a/miners/whatsminer/btminer/M2X/__init__.py +++ b/miners/whatsminer/btminer/M2X/__init__.py @@ -2,5 +2,5 @@ from .M20S import BTMinerM20S from .M20S_Plus import BTMinerM20SPlus from .M21 import BTMinerM21 -from .M21S import BTMinerM21S +from .M21S import BTMinerM21SV20, BTMinerM21SV60 from .M21S_Plus import BTMinerM21SPlus diff --git a/miners/whatsminer/btminer/M3X/M30S.py b/miners/whatsminer/btminer/M3X/M30S.py index 18f85993..3f66e4df 100644 --- a/miners/whatsminer/btminer/M3X/M30S.py +++ b/miners/whatsminer/btminer/M3X/M30S.py @@ -1,8 +1,14 @@ from miners._backends import BTMiner # noqa - Ignore access to _module -from miners._types import M30S # noqa - Ignore access to _module +from miners._types import M30S, M30SV50 # noqa - Ignore access to _module class BTMinerM30S(BTMiner, M30S): def __init__(self, ip: str) -> None: super().__init__(ip) self.ip = ip + + +class BTMinerM30SV50(BTMiner, M30SV50): + def __init__(self, ip: str) -> None: + super().__init__(ip) + self.ip = ip diff --git a/miners/whatsminer/btminer/M3X/__init__.py b/miners/whatsminer/btminer/M3X/__init__.py index 088cd4ce..2fa3dac2 100644 --- a/miners/whatsminer/btminer/M3X/__init__.py +++ b/miners/whatsminer/btminer/M3X/__init__.py @@ -1,4 +1,4 @@ -from .M30S import BTMinerM30S +from .M30S import BTMinerM30S, BTMinerM30SV50 from .M30S_Plus import BTMinerM30SPlus from .M30S_Plus_Plus import BTMinerM30SPlusPlusVG40, BTMinerM30SPlusPlusVG30