From 8e37d72337f8509f4ceb20b6b90659f0e4686966 Mon Sep 17 00:00:00 2001 From: UpstreamData Date: Thu, 13 Apr 2023 13:32:36 -0600 Subject: [PATCH] feature: add support for L3+ and Vnish L3+. --- pyasic/miners/backends/bmminer.py | 32 +++++++++---------- .../miners/ltc/_types/antminer/X3/L3_Plus.py | 25 +++++++++++++++ .../miners/ltc/_types/antminer/X3/__init__.py | 16 ++++++++++ pyasic/miners/ltc/_types/antminer/__init__.py | 1 + pyasic/miners/ltc/antminer/__init__.py | 1 + .../miners/ltc/antminer/bmminer/X3/L3_Plus.py | 23 +++++++++++++ .../ltc/antminer/bmminer/X3/__init__.py | 17 ++++++++++ pyasic/miners/ltc/antminer/bmminer/X7/L7.py | 1 - .../ltc/antminer/bmminer/X7/__init__.py | 1 - .../miners/ltc/antminer/bmminer/__init__.py | 1 + .../miners/ltc/antminer/vnish/X3/L3_Plus.py | 23 +++++++++++++ .../miners/ltc/antminer/vnish/X3/__init__.py | 17 ++++++++++ pyasic/miners/ltc/antminer/vnish/__init__.py | 16 ++++++++++ pyasic/miners/miner_factory.py | 16 ++++++++-- 14 files changed, 169 insertions(+), 21 deletions(-) create mode 100644 pyasic/miners/ltc/_types/antminer/X3/L3_Plus.py create mode 100644 pyasic/miners/ltc/_types/antminer/X3/__init__.py create mode 100644 pyasic/miners/ltc/antminer/bmminer/X3/L3_Plus.py create mode 100644 pyasic/miners/ltc/antminer/bmminer/X3/__init__.py create mode 100644 pyasic/miners/ltc/antminer/vnish/X3/L3_Plus.py create mode 100644 pyasic/miners/ltc/antminer/vnish/X3/__init__.py create mode 100644 pyasic/miners/ltc/antminer/vnish/__init__.py diff --git a/pyasic/miners/backends/bmminer.py b/pyasic/miners/backends/bmminer.py index cf5bab32..97de3377 100644 --- a/pyasic/miners/backends/bmminer.py +++ b/pyasic/miners/backends/bmminer.py @@ -28,25 +28,25 @@ from pyasic.errors import APIError from pyasic.miners.base import BaseMiner BMMINER_DATA_LOC = { - "mac": {"cmd": "mac", "kwargs": {}}, - "model": {"cmd": "model", "kwargs": {"api_devdetails": {"api": "devdetails"}}}, - "api_ver": {"cmd": "api_ver", "kwargs": {"api_version": {"api": "version"}}}, - "fw_ver": {"cmd": "fw_ver", "kwargs": {"api_version": {"api": "version"}}}, - "hostname": {"cmd": "hostname", "kwargs": {}}, - "hashrate": {"cmd": "hashrate", "kwargs": {"api_summary": {"api": "summary"}}}, + "mac": {"cmd": "get_mac", "kwargs": {}}, + "model": {"cmd": "get_model", "kwargs": {"api_devdetails": {"api": "devdetails"}}}, + "api_ver": {"cmd": "get_api_ver", "kwargs": {"api_version": {"api": "version"}}}, + "fw_ver": {"cmd": "get_fw_ver", "kwargs": {"api_version": {"api": "version"}}}, + "hostname": {"cmd": "get_hostname", "kwargs": {}}, + "hashrate": {"cmd": "get_hashrate", "kwargs": {"api_summary": {"api": "summary"}}}, "nominal_hashrate": { - "cmd": "nominal_hashrate", + "cmd": "get_nominal_hashrate", "kwargs": {"api_stats": {"api": "stats"}}, }, - "hashboards": {"cmd": "hashboards", "kwargs": {"api_stats": {"api": "stats"}}}, - "env_temp": {"cmd": "env_temp", "kwargs": {}}, - "wattage": {"cmd": "wattage", "kwargs": {}}, - "wattage_limit": {"cmd": "wattage_limit", "kwargs": {}}, - "fans": {"cmd": "fans", "kwargs": {"api_stats": {"api": "stats"}}}, - "fan_psu": {"cmd": "fan_psu", "kwargs": {}}, - "errors": {"cmd": "errors", "kwargs": {}}, - "fault_light": {"cmd": "fault_light", "kwargs": {}}, - "pools": {"cmd": "pools", "kwargs": {"api_pools": {"api": "pools"}}}, + "hashboards": {"cmd": "get_hashboards", "kwargs": {"api_stats": {"api": "stats"}}}, + "env_temp": {"cmd": "get_env_temp", "kwargs": {}}, + "wattage": {"cmd": "get_wattage", "kwargs": {}}, + "wattage_limit": {"cmd": "get_wattage_limit", "kwargs": {}}, + "fans": {"cmd": "get_fans", "kwargs": {"api_stats": {"api": "stats"}}}, + "fan_psu": {"cmd": "get_fan_psu", "kwargs": {}}, + "errors": {"cmd": "get_errors", "kwargs": {}}, + "fault_light": {"cmd": "get_fault_light", "kwargs": {}}, + "pools": {"cmd": "get_pools", "kwargs": {"api_pools": {"api": "pools"}}}, } diff --git a/pyasic/miners/ltc/_types/antminer/X3/L3_Plus.py b/pyasic/miners/ltc/_types/antminer/X3/L3_Plus.py new file mode 100644 index 00000000..0ef3f45f --- /dev/null +++ b/pyasic/miners/ltc/_types/antminer/X3/L3_Plus.py @@ -0,0 +1,25 @@ +# ------------------------------------------------------------------------------ +# Copyright 2022 Upstream Data Inc - +# - +# Licensed under the Apache License, Version 2.0 (the "License"); - +# you may not use this file except in compliance with the License. - +# You may obtain a copy of the License at - +# - +# http://www.apache.org/licenses/LICENSE-2.0 - +# - +# Unless required by applicable law or agreed to in writing, software - +# distributed under the License is distributed on an "AS IS" BASIS, - +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - +# See the License for the specific language governing permissions and - +# limitations under the License. - +# ------------------------------------------------------------------------------ +from pyasic.miners.makes import AntMiner + + +class L3Plus(AntMiner): # noqa - ignore ABC method implementation + def __init__(self, ip: str, api_ver: str = "0.0.0"): + super().__init__(ip, api_ver) + self.ip = ip + self.model = "L3+" + self.nominal_chips = 0 + self.fan_count = 2 diff --git a/pyasic/miners/ltc/_types/antminer/X3/__init__.py b/pyasic/miners/ltc/_types/antminer/X3/__init__.py new file mode 100644 index 00000000..ebb8b457 --- /dev/null +++ b/pyasic/miners/ltc/_types/antminer/X3/__init__.py @@ -0,0 +1,16 @@ +# ------------------------------------------------------------------------------ +# Copyright 2022 Upstream Data Inc - +# - +# Licensed under the Apache License, Version 2.0 (the "License"); - +# you may not use this file except in compliance with the License. - +# You may obtain a copy of the License at - +# - +# http://www.apache.org/licenses/LICENSE-2.0 - +# - +# Unless required by applicable law or agreed to in writing, software - +# distributed under the License is distributed on an "AS IS" BASIS, - +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - +# See the License for the specific language governing permissions and - +# limitations under the License. - +# ------------------------------------------------------------------------------ +from .L3_Plus import L3Plus diff --git a/pyasic/miners/ltc/_types/antminer/__init__.py b/pyasic/miners/ltc/_types/antminer/__init__.py index ed14989c..13b56661 100644 --- a/pyasic/miners/ltc/_types/antminer/__init__.py +++ b/pyasic/miners/ltc/_types/antminer/__init__.py @@ -13,4 +13,5 @@ # See the License for the specific language governing permissions and - # limitations under the License. - # ------------------------------------------------------------------------------ +from .X3 import * from .X7 import * diff --git a/pyasic/miners/ltc/antminer/__init__.py b/pyasic/miners/ltc/antminer/__init__.py index a21b2ce9..4875fd33 100644 --- a/pyasic/miners/ltc/antminer/__init__.py +++ b/pyasic/miners/ltc/antminer/__init__.py @@ -14,3 +14,4 @@ # limitations under the License. - # ------------------------------------------------------------------------------ from .bmminer import * +from .vnish import * diff --git a/pyasic/miners/ltc/antminer/bmminer/X3/L3_Plus.py b/pyasic/miners/ltc/antminer/bmminer/X3/L3_Plus.py new file mode 100644 index 00000000..48760bdb --- /dev/null +++ b/pyasic/miners/ltc/antminer/bmminer/X3/L3_Plus.py @@ -0,0 +1,23 @@ +# ------------------------------------------------------------------------------ +# Copyright 2022 Upstream Data Inc - +# - +# Licensed under the Apache License, Version 2.0 (the "License"); - +# you may not use this file except in compliance with the License. - +# You may obtain a copy of the License at - +# - +# http://www.apache.org/licenses/LICENSE-2.0 - +# - +# Unless required by applicable law or agreed to in writing, software - +# distributed under the License is distributed on an "AS IS" BASIS, - +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - +# See the License for the specific language governing permissions and - +# limitations under the License. - +# ------------------------------------------------------------------------------ + +from pyasic.miners.backends import AntminerOld +from pyasic.miners.ltc._types import L3Plus # noqa - Ignore access to _module + + +class BMMinerL3Plus(AntminerOld, L3Plus): + def __init__(self, ip: str, api_ver: str = "0.0.0"): + super().__init__(ip, api_ver) diff --git a/pyasic/miners/ltc/antminer/bmminer/X3/__init__.py b/pyasic/miners/ltc/antminer/bmminer/X3/__init__.py new file mode 100644 index 00000000..a147d34c --- /dev/null +++ b/pyasic/miners/ltc/antminer/bmminer/X3/__init__.py @@ -0,0 +1,17 @@ +# ------------------------------------------------------------------------------ +# Copyright 2022 Upstream Data Inc - +# - +# Licensed under the Apache License, Version 2.0 (the "License"); - +# you may not use this file except in compliance with the License. - +# You may obtain a copy of the License at - +# - +# http://www.apache.org/licenses/LICENSE-2.0 - +# - +# Unless required by applicable law or agreed to in writing, software - +# distributed under the License is distributed on an "AS IS" BASIS, - +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - +# See the License for the specific language governing permissions and - +# limitations under the License. - +# ------------------------------------------------------------------------------ + +from .L3_Plus import BMMinerL3Plus diff --git a/pyasic/miners/ltc/antminer/bmminer/X7/L7.py b/pyasic/miners/ltc/antminer/bmminer/X7/L7.py index 4e9ddbd2..7b12e25d 100644 --- a/pyasic/miners/ltc/antminer/bmminer/X7/L7.py +++ b/pyasic/miners/ltc/antminer/bmminer/X7/L7.py @@ -13,7 +13,6 @@ # See the License for the specific language governing permissions and - # limitations under the License. - # ------------------------------------------------------------------------------ - from pyasic.miners.backends import AntminerModern from pyasic.miners.ltc._types import L7 # noqa - Ignore access to _module diff --git a/pyasic/miners/ltc/antminer/bmminer/X7/__init__.py b/pyasic/miners/ltc/antminer/bmminer/X7/__init__.py index 6fa5ae1a..3c343f6d 100644 --- a/pyasic/miners/ltc/antminer/bmminer/X7/__init__.py +++ b/pyasic/miners/ltc/antminer/bmminer/X7/__init__.py @@ -13,5 +13,4 @@ # See the License for the specific language governing permissions and - # limitations under the License. - # ------------------------------------------------------------------------------ - from .L7 import BMMinerL7 diff --git a/pyasic/miners/ltc/antminer/bmminer/__init__.py b/pyasic/miners/ltc/antminer/bmminer/__init__.py index ed14989c..13b56661 100644 --- a/pyasic/miners/ltc/antminer/bmminer/__init__.py +++ b/pyasic/miners/ltc/antminer/bmminer/__init__.py @@ -13,4 +13,5 @@ # See the License for the specific language governing permissions and - # limitations under the License. - # ------------------------------------------------------------------------------ +from .X3 import * from .X7 import * diff --git a/pyasic/miners/ltc/antminer/vnish/X3/L3_Plus.py b/pyasic/miners/ltc/antminer/vnish/X3/L3_Plus.py new file mode 100644 index 00000000..6095cba1 --- /dev/null +++ b/pyasic/miners/ltc/antminer/vnish/X3/L3_Plus.py @@ -0,0 +1,23 @@ +# ------------------------------------------------------------------------------ +# Copyright 2022 Upstream Data Inc - +# - +# Licensed under the Apache License, Version 2.0 (the "License"); - +# you may not use this file except in compliance with the License. - +# You may obtain a copy of the License at - +# - +# http://www.apache.org/licenses/LICENSE-2.0 - +# - +# Unless required by applicable law or agreed to in writing, software - +# distributed under the License is distributed on an "AS IS" BASIS, - +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - +# See the License for the specific language governing permissions and - +# limitations under the License. - +# ------------------------------------------------------------------------------ + +from pyasic.miners.backends import VNish +from pyasic.miners.ltc._types import L3Plus # noqa - Ignore access to _module + + +class VnishL3Plus(VNish, L3Plus): + def __init__(self, ip: str, api_ver: str = "0.0.0"): + super().__init__(ip, api_ver) diff --git a/pyasic/miners/ltc/antminer/vnish/X3/__init__.py b/pyasic/miners/ltc/antminer/vnish/X3/__init__.py new file mode 100644 index 00000000..97a2c81b --- /dev/null +++ b/pyasic/miners/ltc/antminer/vnish/X3/__init__.py @@ -0,0 +1,17 @@ +# ------------------------------------------------------------------------------ +# Copyright 2022 Upstream Data Inc - +# - +# Licensed under the Apache License, Version 2.0 (the "License"); - +# you may not use this file except in compliance with the License. - +# You may obtain a copy of the License at - +# - +# http://www.apache.org/licenses/LICENSE-2.0 - +# - +# Unless required by applicable law or agreed to in writing, software - +# distributed under the License is distributed on an "AS IS" BASIS, - +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - +# See the License for the specific language governing permissions and - +# limitations under the License. - +# ------------------------------------------------------------------------------ + +from .L3_Plus import VnishL3Plus diff --git a/pyasic/miners/ltc/antminer/vnish/__init__.py b/pyasic/miners/ltc/antminer/vnish/__init__.py new file mode 100644 index 00000000..647fb882 --- /dev/null +++ b/pyasic/miners/ltc/antminer/vnish/__init__.py @@ -0,0 +1,16 @@ +# ------------------------------------------------------------------------------ +# Copyright 2022 Upstream Data Inc - +# - +# Licensed under the Apache License, Version 2.0 (the "License"); - +# you may not use this file except in compliance with the License. - +# You may obtain a copy of the License at - +# - +# http://www.apache.org/licenses/LICENSE-2.0 - +# - +# Unless required by applicable law or agreed to in writing, software - +# distributed under the License is distributed on an "AS IS" BASIS, - +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - +# See the License for the specific language governing permissions and - +# limitations under the License. - +# ------------------------------------------------------------------------------ +from .X3 import * diff --git a/pyasic/miners/miner_factory.py b/pyasic/miners/miner_factory.py index 5e17d986..38040dd3 100644 --- a/pyasic/miners/miner_factory.py +++ b/pyasic/miners/miner_factory.py @@ -54,6 +54,11 @@ MINER_CLASSES = { "Default": CGMinerHS3, "CGMiner": CGMinerHS3, }, + "ANTMINER L3+": { + "Default": BMMinerL3Plus, + "BMMiner": BMMinerL3Plus, + "VNish": VnishL3Plus, + }, "ANTMINER L7": { "Default": BMMinerL7, "BMMiner": BMMinerL7, @@ -632,9 +637,6 @@ class MinerFactory(metaclass=Singleton): logging.warning(f"{ip}: Get Miner Timed Out") miner = self._select_miner_from_classes(ip, model, api, ver, api_ver) - # once we have the miner, get the api and firmware version - # await miner.get_version() - # save the miner to the cache at its IP if its not unknown if not isinstance(miner, UnknownMiner): self.miners[ip] = miner @@ -700,6 +702,7 @@ class MinerFactory(metaclass=Singleton): try: devdetails, version = await self.__get_devdetails_and_version(ip) + print(devdetails, version) except APIError as e: # catch APIError and let the factory know we cant get data logging.warning(f"{ip}: API Command Error: {e}") @@ -842,10 +845,17 @@ class MinerFactory(metaclass=Singleton): if version and not model: try: model = version["VERSION"][0]["Type"].upper() + print(model) if "ANTMINER BHB" in model: # def antminer, get from web sysinfo = await self.__get_system_info_from_web(str(ip)) model = sysinfo["minertype"].upper() + if "VNISH" in model: + api = "VNish" + for split_point in [" BB", " XILINX", " (VNISH"]: + if split_point in model: + model = model.split(split_point)[0] + except KeyError: pass