feature: add support for Avalon Nano 3.

This commit is contained in:
Brett Rowan
2024-09-01 13:21:53 -06:00
parent a57f343dcc
commit 477acda1c1
9 changed files with 61 additions and 4 deletions

View File

@@ -284,6 +284,7 @@ class AvalonminerModels(str, Enum):
Avalon1066 = "Avalon 1066"
Avalon1166Pro = "Avalon 1166 Pro"
Avalon1246 = "Avalon 1246"
AvalonNano3 = "Avalon Nano 3"
def __str__(self):
return self.value

View File

@@ -20,3 +20,4 @@ from .A9X import *
from .A10X import *
from .A11X import *
from .A12X import *
from .nano import *

View 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 .nano3 import CGMinerAvalonNano3

View File

@@ -0,0 +1,22 @@
# ------------------------------------------------------------------------------
# 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 AvalonMiner
from pyasic.miners.device.models import AvalonNano3
class CGMinerAvalonNano3(AvalonMiner, AvalonNano3):
pass

View File

@@ -118,12 +118,13 @@ class AvalonMiner(CGMiner):
stats_items = []
stats_dict = {}
for item in _stats_items:
if ":" in item:
if ": " in item:
data = item.replace("]", "").split("[")
data_list = [i.split(": ") for i in data[1].strip().split(", ")]
data_dict = {}
try:
for key, val in [tuple(item) for item in data_list]:
print(key, val)
data_dict[key] = val
except ValueError:
# --avalon args
@@ -220,7 +221,7 @@ class AvalonMiner(CGMiner):
try:
board_hr = parsed_stats["MGHS"][board]
hashboards[board].hashrate = AlgoHashRate.SHA256(
board_hr, HashUnit.SHA256.GH
float(board_hr), HashUnit.SHA256.GH
).into(self.algo.unit.default)
except LookupError:
pass

View File

@@ -20,3 +20,4 @@ from .A9X import *
from .A10X import *
from .A11X import *
from .A12X import *
from .nano import *

View File

@@ -0,0 +1 @@
from .nano3 import AvalonNano3

View File

@@ -0,0 +1,10 @@
from pyasic.device import MinerModel
from pyasic.miners.device.makes import AvalonMinerMake
class AvalonNano3(AvalonMinerMake):
raw_model = MinerModel.AVALONMINER.AvalonNano3
expected_hashboards = 1
expected_chips = 10
expected_fans = 1

View File

@@ -332,6 +332,7 @@ MINER_CLASSES = {
"AVALONMINER 1066": CGMinerAvalon1066,
"AVALONMINER 1166PRO": CGMinerAvalon1166Pro,
"AVALONMINER 1246": CGMinerAvalon1246,
"AVALONMINER NANO3": CGMinerAvalonNano3,
},
MinerTypes.INNOSILICON: {
None: type("InnosiliconUnknown", (Innosilicon, InnosiliconMake), {}),
@@ -906,10 +907,12 @@ class MinerFactory:
async def get_miner_model_avalonminer(self, ip: str) -> str | None:
sock_json_data = await self.send_api_command(ip, "version")
try:
miner_model = sock_json_data["VERSION"][0]["PROD"]
miner_model = sock_json_data["VERSION"][0]["PROD"].upper()
if "-" in miner_model:
miner_model = miner_model.split("-")[0]
if miner_model == "AVALONNANO":
nano_subtype = sock_json_data["VERSION"][0]["MODEL"].upper()
miner_model = f"AVALONMINER {nano_subtype}"
return miner_model
except (TypeError, LookupError):
pass