feature: add Avalonminer support in update miner factory, and add support for A1166 and A1246.
This commit is contained in:
29
pyasic/miners/btc/_types/avalonminer/A11X/A1166.py
Normal file
29
pyasic/miners/btc/_types/avalonminer/A11X/A1166.py
Normal file
@@ -0,0 +1,29 @@
|
||||
# ------------------------------------------------------------------------------
|
||||
# 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. -
|
||||
# ------------------------------------------------------------------------------
|
||||
import warnings
|
||||
|
||||
from pyasic.miners.makes import AvalonMiner
|
||||
|
||||
|
||||
class Avalon1166Pro(AvalonMiner): # 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 = "Avalon 1166"
|
||||
warnings.warn(
|
||||
f"Unknown chip count for miner type {self.model}, please open an issue on GitHub (https://github.com/UpstreamData/pyasic)."
|
||||
)
|
||||
self.fan_count = 4
|
||||
18
pyasic/miners/btc/_types/avalonminer/A11X/__init__.py
Normal file
18
pyasic/miners/btc/_types/avalonminer/A11X/__init__.py
Normal file
@@ -0,0 +1,18 @@
|
||||
# ------------------------------------------------------------------------------
|
||||
# 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 .A1166 import Avalon1166Pro
|
||||
29
pyasic/miners/btc/_types/avalonminer/A12X/A1246.py
Normal file
29
pyasic/miners/btc/_types/avalonminer/A12X/A1246.py
Normal file
@@ -0,0 +1,29 @@
|
||||
# ------------------------------------------------------------------------------
|
||||
# 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. -
|
||||
# ------------------------------------------------------------------------------
|
||||
import warnings
|
||||
|
||||
from pyasic.miners.makes import AvalonMiner
|
||||
|
||||
|
||||
class Avalon1246(AvalonMiner): # 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 = "Avalon 1246"
|
||||
warnings.warn(
|
||||
f"Unknown chip count for miner type {self.model}, please open an issue on GitHub (https://github.com/UpstreamData/pyasic)."
|
||||
)
|
||||
self.fan_count = 4
|
||||
17
pyasic/miners/btc/_types/avalonminer/A12X/__init__.py
Normal file
17
pyasic/miners/btc/_types/avalonminer/A12X/__init__.py
Normal file
@@ -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 .A1246 import Avalon1246
|
||||
@@ -18,3 +18,5 @@ from .A7X import *
|
||||
from .A8X import *
|
||||
from .A9X import *
|
||||
from .A10X import *
|
||||
from .A11X import *
|
||||
from .A12X import *
|
||||
|
||||
23
pyasic/miners/btc/avalonminer/cgminer/A11X/A1166.py
Normal file
23
pyasic/miners/btc/avalonminer/cgminer/A11X/A1166.py
Normal file
@@ -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.btc._types import Avalon1166Pro # noqa
|
||||
|
||||
from .A11X import CGMinerA11X
|
||||
|
||||
|
||||
class CGMinerAvalon1166Pro(CGMinerA11X, Avalon1166Pro):
|
||||
pass
|
||||
21
pyasic/miners/btc/avalonminer/cgminer/A11X/A11X.py
Normal file
21
pyasic/miners/btc/avalonminer/cgminer/A11X/A11X.py
Normal file
@@ -0,0 +1,21 @@
|
||||
# ------------------------------------------------------------------------------
|
||||
# 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 CGMinerAvalon # noqa - Ignore access to _module
|
||||
|
||||
|
||||
class CGMinerA11X(CGMinerAvalon):
|
||||
pass
|
||||
17
pyasic/miners/btc/avalonminer/cgminer/A11X/__init__.py
Normal file
17
pyasic/miners/btc/avalonminer/cgminer/A11X/__init__.py
Normal file
@@ -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 .A1166 import CGMinerAvalon1166Pro
|
||||
23
pyasic/miners/btc/avalonminer/cgminer/A12X/A1246.py
Normal file
23
pyasic/miners/btc/avalonminer/cgminer/A12X/A1246.py
Normal file
@@ -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.btc._types import Avalon1246
|
||||
|
||||
from .A12X import CGMinerA12X
|
||||
|
||||
|
||||
class CGMinerAvalon1246(CGMinerA12X, Avalon1246):
|
||||
pass
|
||||
21
pyasic/miners/btc/avalonminer/cgminer/A12X/A12X.py
Normal file
21
pyasic/miners/btc/avalonminer/cgminer/A12X/A12X.py
Normal file
@@ -0,0 +1,21 @@
|
||||
# ------------------------------------------------------------------------------
|
||||
# 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 CGMinerAvalon # noqa - Ignore access to _module
|
||||
|
||||
|
||||
class CGMinerA12X(CGMinerAvalon):
|
||||
pass
|
||||
17
pyasic/miners/btc/avalonminer/cgminer/A12X/__init__.py
Normal file
17
pyasic/miners/btc/avalonminer/cgminer/A12X/__init__.py
Normal file
@@ -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 .A1246 import CGMinerAvalon1246
|
||||
@@ -18,3 +18,5 @@ from .A7X import *
|
||||
from .A8X import *
|
||||
from .A9X import *
|
||||
from .A10X import *
|
||||
from .A11X import *
|
||||
from .A12X import *
|
||||
|
||||
@@ -65,7 +65,7 @@ class MinerTypes(enum.Enum):
|
||||
|
||||
MINER_CLASSES = {
|
||||
MinerTypes.ANTMINER: {
|
||||
# None: BMMiner,
|
||||
None: BMMiner,
|
||||
"ANTMINER DR5": CGMinerDR5,
|
||||
"ANTMINER D3": CGMinerD3,
|
||||
"ANTMINER HS3": CGMinerHS3,
|
||||
@@ -97,7 +97,7 @@ MINER_CLASSES = {
|
||||
"ANTMINER T19": BMMinerT19,
|
||||
},
|
||||
MinerTypes.WHATSMINER: {
|
||||
# None: BTMiner,
|
||||
None: BTMiner,
|
||||
"M20V10": BTMinerM20V10,
|
||||
"M20SV10": BTMinerM20SV10,
|
||||
"M20SV20": BTMinerM20SV20,
|
||||
@@ -280,7 +280,7 @@ MINER_CLASSES = {
|
||||
"M59VH30": BTMinerM59VH30,
|
||||
},
|
||||
MinerTypes.AVALONMINER: {
|
||||
# None: CGMinerAvalon,
|
||||
None: CGMinerAvalon,
|
||||
"AVALONMINER 721": CGMinerAvalon721,
|
||||
"AVALONMINER 741": CGMinerAvalon741,
|
||||
"AVALONMINER 761": CGMinerAvalon761,
|
||||
@@ -291,21 +291,23 @@ MINER_CLASSES = {
|
||||
"AVALONMINER 1026": CGMinerAvalon1026,
|
||||
"AVALONMINER 1047": CGMinerAvalon1047,
|
||||
"AVALONMINER 1066": CGMinerAvalon1066,
|
||||
"AVALONMINER 1166PRO": CGMinerAvalon1166Pro,
|
||||
"AVALONMINER 1246": CGMinerAvalon1246,
|
||||
},
|
||||
MinerTypes.INNOSILICON: {
|
||||
# None: CGMiner,
|
||||
None: CGMiner,
|
||||
"T3H+": CGMinerInnosiliconT3HPlus,
|
||||
"A10X": CGMinerA10X,
|
||||
},
|
||||
MinerTypes.GOLDSHELL: {
|
||||
# None: BFGMiner,
|
||||
None: BFGMiner,
|
||||
"GOLDSHELL CK5": BFGMinerCK5,
|
||||
"GOLDSHELL HS5": BFGMinerHS5,
|
||||
"GOLDSHELL KD5": BFGMinerKD5,
|
||||
"GOLDSHELL KDMAX": BFGMinerKDMax,
|
||||
},
|
||||
MinerTypes.BRAIINS_OS: {
|
||||
# None: BOSMiner,
|
||||
None: BOSMiner,
|
||||
"ANTMINER S9": BOSMinerS9,
|
||||
"ANTMINER S17": BOSMinerS17,
|
||||
"ANTMINER S17+": BOSMinerS17Plus,
|
||||
@@ -322,7 +324,7 @@ MINER_CLASSES = {
|
||||
"ANTMINER T19": BOSMinerT19,
|
||||
},
|
||||
MinerTypes.VNISH: {
|
||||
# None: VNish,
|
||||
None: VNish,
|
||||
"ANTMINER L3+": VnishL3Plus,
|
||||
"ANTMINER S19": VNishS19,
|
||||
"ANTMINER S19 PRO": VNishS19Pro,
|
||||
@@ -333,7 +335,7 @@ MINER_CLASSES = {
|
||||
"ANTMINER T19": VNishT19,
|
||||
},
|
||||
MinerTypes.HIVEON: {
|
||||
# None: Hiveon,
|
||||
None: Hiveon,
|
||||
"ANTMINER T9": HiveonT9,
|
||||
},
|
||||
}
|
||||
@@ -442,16 +444,6 @@ class MinerFactory:
|
||||
pass
|
||||
return None, None
|
||||
|
||||
async def _get_miner_socket(self, ip: str):
|
||||
commands = ["devdetails", "version"]
|
||||
tasks = [asyncio.create_task(self._socket_ping(ip, cmd)) for cmd in commands]
|
||||
|
||||
data = await concurrent_get_first_result(
|
||||
tasks, lambda x: x is not None and self._parse_socket_type(x) is not None
|
||||
)
|
||||
if data is not None:
|
||||
return self._parse_socket_type(data)
|
||||
|
||||
@staticmethod
|
||||
def _parse_web_type(web_text: str, web_resp: aiohttp.ClientResponse) -> MinerTypes:
|
||||
if web_resp.status == 401 and 'realm="antMiner' in web_resp.headers.get(
|
||||
@@ -468,6 +460,18 @@ class MinerFactory:
|
||||
return MinerTypes.GOLDSHELL
|
||||
if "AnthillOS" in web_text:
|
||||
return MinerTypes.VNISH
|
||||
if "Avalon" in web_text:
|
||||
return MinerTypes.AVALONMINER
|
||||
|
||||
async def _get_miner_socket(self, ip: str):
|
||||
commands = ["devdetails", "version"]
|
||||
tasks = [asyncio.create_task(self._socket_ping(ip, cmd)) for cmd in commands]
|
||||
|
||||
data = await concurrent_get_first_result(
|
||||
tasks, lambda x: x is not None and self._parse_socket_type(x) is not None
|
||||
)
|
||||
if data is not None:
|
||||
return self._parse_socket_type(data)
|
||||
|
||||
@staticmethod
|
||||
async def _socket_ping(ip: str, cmd: str) -> Optional[str]:
|
||||
@@ -529,6 +533,8 @@ class MinerFactory:
|
||||
return MinerTypes.ANTMINER
|
||||
if "INTCHAINS_QOMO" in upper_data:
|
||||
return MinerTypes.GOLDSHELL
|
||||
if "AVALON" in upper_data:
|
||||
return MinerTypes.AVALONMINER
|
||||
|
||||
async def send_web_command(
|
||||
self,
|
||||
@@ -690,7 +696,7 @@ class MinerFactory:
|
||||
return self._select_miner_from_classes(
|
||||
ip=IPv4Address(ip),
|
||||
miner_model=miner_model,
|
||||
miner_type=MinerTypes.BRAIINS_OS,
|
||||
miner_type=MinerTypes.WHATSMINER,
|
||||
)
|
||||
except (TypeError, LookupError):
|
||||
pass
|
||||
@@ -700,6 +706,20 @@ class MinerFactory:
|
||||
)
|
||||
|
||||
async def get_miner_avalonminer(self, ip: str):
|
||||
sock_json_data = await self.send_api_command(ip, "version")
|
||||
try:
|
||||
miner_model = sock_json_data["VERSION"][0]["PROD"]
|
||||
if "-" in miner_model:
|
||||
miner_model = miner_model.split("-")
|
||||
|
||||
return self._select_miner_from_classes(
|
||||
ip=IPv4Address(ip),
|
||||
miner_model=miner_model,
|
||||
miner_type=MinerTypes.AVALONMINER,
|
||||
)
|
||||
except (TypeError, LookupError):
|
||||
pass
|
||||
|
||||
return self._select_miner_from_classes(
|
||||
ip=ip, miner_model=None, miner_type=MinerTypes.AVALONMINER
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user