Skip to content

Commit

Permalink
fixed some bugs and added support for M20Sv10 and 20
Browse files Browse the repository at this point in the history
  • Loading branch information
UpstreamData committed Jul 14, 2022
1 parent aaf0d7f commit 13b583b
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 18 deletions.
18 changes: 18 additions & 0 deletions pyasic/miners/_types/whatsminer/M2X/M20S.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,21 @@ def __init__(self, ip: str):
self.model = "M20S"
self.nominal_chips = 66
self.fan_count = 2


class M20SV10(BaseMiner):
def __init__(self, ip: str):
super().__init__()
self.ip = ip
self.model = "M20S"
self.nominal_chips = 105
self.fan_count = 2


class M20SV20(BaseMiner):
def __init__(self, ip: str):
super().__init__()
self.ip = ip
self.model = "M20S"
self.nominal_chips = 111
self.fan_count = 2
2 changes: 1 addition & 1 deletion pyasic/miners/_types/whatsminer/M2X/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .M20S import M20S
from .M20S import M20S, M20SV10, M20SV20
from .M20S_Plus import M20SPlus

from .M21 import M21
Expand Down
26 changes: 14 additions & 12 deletions pyasic/miners/miner_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@
"M20S": {
"Default": BTMinerM20S,
"BTMiner": BTMinerM20S,
"10": BTMinerM20SV10,
"20": BTMinerM20SV20,
},
"M20S+": {
"Default": BTMinerM20SPlus,
Expand Down Expand Up @@ -452,24 +454,24 @@ async def _get_miner_type(
if "BOSminer+" in version["VERSION"][0].keys():
api = "BOSMiner+"

# check for avalonminers
if version["VERSION"][0].get("PROD"):
_data = version["VERSION"][0]["PROD"].split("-")
model = _data[0]
if len(data) > 1:
ver = _data[1]
elif version["VERSION"][0].get("MODEL"):
_data = version["VERSION"][0]["MODEL"].split("-")
model = f"AvalonMiner {_data[0]}"
if len(data) > 1:
ver = _data[1]

# if all that fails, check the Description to see if it is a whatsminer
if version.get("Description") and (
"whatsminer" in version.get("Description")
):
api = "BTMiner"

# check for avalonminers
if version["VERSION"][0].get("PROD"):
_data = version["VERSION"][0]["PROD"].split("-")
model = _data[0]
if len(data) > 1:
ver = _data[1]
elif version["VERSION"][0].get("MODEL"):
_data = version["VERSION"][0]["MODEL"].split("-")
model = f"AvalonMiner {_data[0]}"
if len(data) > 1:
ver = _data[1]

# if we have no model from devdetails but have version, try to get it from there
if version and not model:
# make sure version isn't blank
Expand Down
18 changes: 17 additions & 1 deletion pyasic/miners/whatsminer/btminer/M2X/M20S.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,24 @@
from pyasic.miners._backends import BTMiner # noqa - Ignore access to _module
from pyasic.miners._types import M20S # noqa - Ignore access to _module
from pyasic.miners._types import ( # noqa - Ignore access to _module
M20S,
M20SV10,
M20SV20,
)


class BTMinerM20S(BTMiner, M20S):
def __init__(self, ip: str) -> None:
super().__init__(ip)
self.ip = ip


class BTMinerM20SV10(BTMiner, M20SV10):
def __init__(self, ip: str) -> None:
super().__init__(ip)
self.ip = ip


class BTMinerM20SV20(BTMiner, M20SV20):
def __init__(self, ip: str) -> None:
super().__init__(ip)
self.ip = ip
2 changes: 1 addition & 1 deletion pyasic/miners/whatsminer/btminer/M2X/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .M20S import BTMinerM20S
from .M20S import BTMinerM20S, BTMinerM20SV10, BTMinerM20SV20
from .M20S_Plus import BTMinerM20SPlus

from .M21 import BTMinerM21
Expand Down
6 changes: 3 additions & 3 deletions pyasic/network/net_range.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ class MinerNetworkRange:
Parameters:
ip_range: ## A range of IP addresses to put in the network, or a list of IPs
* Takes a string formatted as:
* {ip_range_1_start}-{ip_range_1_end}, {ip_address_1}, {ip_range_2_start}-{ip_range_2_end}, {ip_address_2}...
* Also takes a list of strings formatted as:
* [{ip_address_1}, {ip_address_2}, {ip_address_3}, ...]
```f"{ip_range_1_start}-{ip_range_1_end}, {ip_address_1}, {ip_range_2_start}-{ip_range_2_end}, {ip_address_2}..."```
* Also takes a list of strings or `ipaddress.ipaddress` formatted as:
```[{ip_address_1}, {ip_address_2}, {ip_address_3}, ...]```
"""

def __init__(self, ip_range: Union[str, list]):
Expand Down

0 comments on commit 13b583b

Please sign in to comment.