Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
39410424b6 | ||
|
|
7cb871b541 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -7,4 +7,3 @@ pyvenv.cfg
|
||||
bin/
|
||||
lib/
|
||||
.idea/
|
||||
.vs/
|
||||
@@ -23,7 +23,7 @@ Welcome to `pyasic`! `pyasic` uses an asynchronous method of communicating with
|
||||
## Installation
|
||||
|
||||
It is recommended to install `pyasic` in a [virtual environment](https://realpython.com/python-virtual-environments-a-primer/#what-other-popular-options-exist-aside-from-venv) to isolate it from the rest of your system. Options include:
|
||||
- [pypoetry](https://python-poetry.org/): the reccommended way, since pyasic already uses it by default. Use version 2.0+
|
||||
- [pypoetry](https://python-poetry.org/): the reccommended way, since pyasic already uses it by default
|
||||
|
||||
```
|
||||
poetry install
|
||||
|
||||
@@ -157,19 +157,6 @@
|
||||
show_root_heading: false
|
||||
heading_level: 0
|
||||
|
||||
## S19j Pro+ (Stock)
|
||||
|
||||
- [x] Shutdowns
|
||||
- [x] Power Modes
|
||||
- [ ] Setpoints
|
||||
- [ ] Presets
|
||||
|
||||
::: pyasic.miners.antminer.bmminer.X19.S19.BMMinerS19jProPlus
|
||||
handler: python
|
||||
options:
|
||||
show_root_heading: false
|
||||
heading_level: 0
|
||||
|
||||
## S19j XP (Stock)
|
||||
|
||||
- [x] Shutdowns
|
||||
@@ -183,19 +170,6 @@
|
||||
show_root_heading: false
|
||||
heading_level: 0
|
||||
|
||||
## S19j+ (Stock)
|
||||
|
||||
- [x] Shutdowns
|
||||
- [x] Power Modes
|
||||
- [ ] Setpoints
|
||||
- [ ] Presets
|
||||
|
||||
::: pyasic.miners.antminer.bmminer.X19.S19.BMMinerS19jPlus
|
||||
handler: python
|
||||
options:
|
||||
show_root_heading: false
|
||||
heading_level: 0
|
||||
|
||||
## S19j No PIC (Stock)
|
||||
|
||||
- [x] Shutdowns
|
||||
@@ -313,19 +287,6 @@
|
||||
show_root_heading: false
|
||||
heading_level: 0
|
||||
|
||||
## S19 XP Hydro (BOS+)
|
||||
|
||||
- [x] Shutdowns
|
||||
- [ ] Power Modes
|
||||
- [x] Setpoints
|
||||
- [ ] Presets
|
||||
|
||||
::: pyasic.miners.antminer.bosminer.X19.S19.BOSMinerS19XPHydro
|
||||
handler: python
|
||||
options:
|
||||
show_root_heading: false
|
||||
heading_level: 0
|
||||
|
||||
## S19+ (BOS+)
|
||||
|
||||
- [x] Shutdowns
|
||||
@@ -482,19 +443,6 @@
|
||||
show_root_heading: false
|
||||
heading_level: 0
|
||||
|
||||
## S19 Hydro (VNish)
|
||||
|
||||
- [x] Shutdowns
|
||||
- [ ] Power Modes
|
||||
- [x] Setpoints
|
||||
- [x] Presets
|
||||
|
||||
::: pyasic.miners.antminer.vnish.X19.S19.VNishS19Hydro
|
||||
handler: python
|
||||
options:
|
||||
show_root_heading: false
|
||||
heading_level: 0
|
||||
|
||||
## S19 Pro (VNish)
|
||||
|
||||
- [x] Shutdowns
|
||||
@@ -508,19 +456,6 @@
|
||||
show_root_heading: false
|
||||
heading_level: 0
|
||||
|
||||
## S19 Pro A (VNish)
|
||||
|
||||
- [x] Shutdowns
|
||||
- [ ] Power Modes
|
||||
- [x] Setpoints
|
||||
- [x] Presets
|
||||
|
||||
::: pyasic.miners.antminer.vnish.X19.S19.VNishS19ProA
|
||||
handler: python
|
||||
options:
|
||||
show_root_heading: false
|
||||
heading_level: 0
|
||||
|
||||
## S19 Pro Hydro (VNish)
|
||||
|
||||
- [x] Shutdowns
|
||||
@@ -534,32 +469,6 @@
|
||||
show_root_heading: false
|
||||
heading_level: 0
|
||||
|
||||
## S19 XP (VNish)
|
||||
|
||||
- [x] Shutdowns
|
||||
- [ ] Power Modes
|
||||
- [x] Setpoints
|
||||
- [x] Presets
|
||||
|
||||
::: pyasic.miners.antminer.vnish.X19.S19.VNishS19XP
|
||||
handler: python
|
||||
options:
|
||||
show_root_heading: false
|
||||
heading_level: 0
|
||||
|
||||
## S19 XP Hydro (VNish)
|
||||
|
||||
- [x] Shutdowns
|
||||
- [ ] Power Modes
|
||||
- [x] Setpoints
|
||||
- [x] Presets
|
||||
|
||||
::: pyasic.miners.antminer.vnish.X19.S19.VNishS19XPHydro
|
||||
handler: python
|
||||
options:
|
||||
show_root_heading: false
|
||||
heading_level: 0
|
||||
|
||||
## S19a (VNish)
|
||||
|
||||
- [x] Shutdowns
|
||||
|
||||
@@ -92,19 +92,6 @@
|
||||
show_root_heading: false
|
||||
heading_level: 0
|
||||
|
||||
## S21 Hydro (BOS+)
|
||||
|
||||
- [x] Shutdowns
|
||||
- [ ] Power Modes
|
||||
- [x] Setpoints
|
||||
- [ ] Presets
|
||||
|
||||
::: pyasic.miners.antminer.bosminer.X21.S21.BOSMinerS21Hydro
|
||||
handler: python
|
||||
options:
|
||||
show_root_heading: false
|
||||
heading_level: 0
|
||||
|
||||
## S21 Pro (BOS+)
|
||||
|
||||
- [x] Shutdowns
|
||||
@@ -118,32 +105,6 @@
|
||||
show_root_heading: false
|
||||
heading_level: 0
|
||||
|
||||
## S21+ (BOS+)
|
||||
|
||||
- [x] Shutdowns
|
||||
- [ ] Power Modes
|
||||
- [x] Setpoints
|
||||
- [ ] Presets
|
||||
|
||||
::: pyasic.miners.antminer.bosminer.X21.S21.BOSMinerS21Plus
|
||||
handler: python
|
||||
options:
|
||||
show_root_heading: false
|
||||
heading_level: 0
|
||||
|
||||
## S21+ Hydro (BOS+)
|
||||
|
||||
- [x] Shutdowns
|
||||
- [ ] Power Modes
|
||||
- [x] Setpoints
|
||||
- [ ] Presets
|
||||
|
||||
::: pyasic.miners.antminer.bosminer.X21.S21.BOSMinerS21PlusHydro
|
||||
handler: python
|
||||
options:
|
||||
show_root_heading: false
|
||||
heading_level: 0
|
||||
|
||||
## T21 (BOS+)
|
||||
|
||||
- [x] Shutdowns
|
||||
@@ -170,58 +131,6 @@
|
||||
show_root_heading: false
|
||||
heading_level: 0
|
||||
|
||||
## S21 Hydro (VNish)
|
||||
|
||||
- [x] Shutdowns
|
||||
- [ ] Power Modes
|
||||
- [x] Setpoints
|
||||
- [x] Presets
|
||||
|
||||
::: pyasic.miners.antminer.vnish.X21.S21.VNishS21Hydro
|
||||
handler: python
|
||||
options:
|
||||
show_root_heading: false
|
||||
heading_level: 0
|
||||
|
||||
## S21 Pro (VNish)
|
||||
|
||||
- [x] Shutdowns
|
||||
- [ ] Power Modes
|
||||
- [x] Setpoints
|
||||
- [x] Presets
|
||||
|
||||
::: pyasic.miners.antminer.vnish.X21.S21.VNishS21Pro
|
||||
handler: python
|
||||
options:
|
||||
show_root_heading: false
|
||||
heading_level: 0
|
||||
|
||||
## S21+ (VNish)
|
||||
|
||||
- [x] Shutdowns
|
||||
- [ ] Power Modes
|
||||
- [x] Setpoints
|
||||
- [x] Presets
|
||||
|
||||
::: pyasic.miners.antminer.vnish.X21.S21.VNishS21Plus
|
||||
handler: python
|
||||
options:
|
||||
show_root_heading: false
|
||||
heading_level: 0
|
||||
|
||||
## S21+ Hydro (VNish)
|
||||
|
||||
- [x] Shutdowns
|
||||
- [ ] Power Modes
|
||||
- [x] Setpoints
|
||||
- [x] Presets
|
||||
|
||||
::: pyasic.miners.antminer.vnish.X21.S21.VNishS21PlusHydro
|
||||
handler: python
|
||||
options:
|
||||
show_root_heading: false
|
||||
heading_level: 0
|
||||
|
||||
## T21 (VNish)
|
||||
|
||||
- [x] Shutdowns
|
||||
|
||||
@@ -73,7 +73,7 @@
|
||||
- [x] Setpoints
|
||||
- [x] Presets
|
||||
|
||||
::: pyasic.miners.antminer.vnish.X3.L3.VNishL3Plus
|
||||
::: pyasic.miners.antminer.vnish.X3.L3.VnishL3Plus
|
||||
handler: python
|
||||
options:
|
||||
show_root_heading: false
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
- [x] Setpoints
|
||||
- [x] Presets
|
||||
|
||||
::: pyasic.miners.antminer.vnish.X7.L7.VNishL7
|
||||
::: pyasic.miners.antminer.vnish.X7.L7.VnishL7
|
||||
handler: python
|
||||
options:
|
||||
show_root_heading: false
|
||||
|
||||
@@ -105,19 +105,6 @@
|
||||
show_root_heading: false
|
||||
heading_level: 0
|
||||
|
||||
## L9 (VNish)
|
||||
|
||||
- [x] Shutdowns
|
||||
- [ ] Power Modes
|
||||
- [x] Setpoints
|
||||
- [x] Presets
|
||||
|
||||
::: pyasic.miners.antminer.vnish.X9.L9.VNishL9
|
||||
handler: python
|
||||
options:
|
||||
show_root_heading: false
|
||||
heading_level: 0
|
||||
|
||||
## T9 (Hive)
|
||||
|
||||
- [ ] Shutdowns
|
||||
|
||||
@@ -1,19 +1,6 @@
|
||||
# pyasic
|
||||
## DGX Models
|
||||
|
||||
## DG1 (Stock)
|
||||
|
||||
- [ ] Shutdowns
|
||||
- [ ] Power Modes
|
||||
- [ ] Setpoints
|
||||
- [ ] Presets
|
||||
|
||||
::: pyasic.miners.elphapex.daoge.DGX.DG1.ElphapexDG1
|
||||
handler: python
|
||||
options:
|
||||
show_root_heading: false
|
||||
heading_level: 0
|
||||
|
||||
## DG1+ (Stock)
|
||||
|
||||
- [ ] Shutdowns
|
||||
@@ -27,16 +14,3 @@
|
||||
show_root_heading: false
|
||||
heading_level: 0
|
||||
|
||||
## DG1Home (Stock)
|
||||
|
||||
- [ ] Shutdowns
|
||||
- [ ] Power Modes
|
||||
- [ ] Setpoints
|
||||
- [ ] Presets
|
||||
|
||||
::: pyasic.miners.elphapex.daoge.DGX.DG1.ElphapexDG1Home
|
||||
handler: python
|
||||
options:
|
||||
show_root_heading: false
|
||||
heading_level: 0
|
||||
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
# pyasic
|
||||
## Byte Models
|
||||
|
||||
## Byte (Stock)
|
||||
|
||||
- [x] Shutdowns
|
||||
- [x] Power Modes
|
||||
- [ ] Setpoints
|
||||
- [ ] Presets
|
||||
|
||||
::: pyasic.miners.goldshell.bfgminer.Byte.Byte.GoldshellByte
|
||||
handler: python
|
||||
options:
|
||||
show_root_heading: false
|
||||
heading_level: 0
|
||||
|
||||
@@ -86,8 +86,6 @@ details {
|
||||
<li><a href="../antminer/X19#s19j-no-pic-stock">S19j No PIC (Stock)</a></li>
|
||||
<li><a href="../antminer/X19#s19-pro_1-stock">S19 Pro+ (Stock)</a></li>
|
||||
<li><a href="../antminer/X19#s19j-pro-stock">S19j Pro (Stock)</a></li>
|
||||
<li><a href="../antminer/X19#s19j_1-stock">S19j+ (Stock)</a></li>
|
||||
<li><a href="../antminer/X19#s19j-pro_1-stock">S19j Pro+ (Stock)</a></li>
|
||||
<li><a href="../antminer/X19#s19-xp-stock">S19 XP (Stock)</a></li>
|
||||
<li><a href="../antminer/X19#s19a-stock">S19a (Stock)</a></li>
|
||||
<li><a href="../antminer/X19#s19a-pro-stock">S19a Pro (Stock)</a></li>
|
||||
@@ -107,7 +105,6 @@ details {
|
||||
<li><a href="../antminer/X21#s21-stock">S21 (Stock)</a></li>
|
||||
<li><a href="../antminer/X21#s21_1-stock">S21+ (Stock)</a></li>
|
||||
<li><a href="../antminer/X21#s21_1-hydro-stock">S21+ Hydro (Stock)</a></li>
|
||||
<li><a href="../antminer/X21#s21_1-hydro-stock">S21+ Hydro (Stock)</a></li>
|
||||
<li><a href="../antminer/X21#s21-pro-stock">S21 Pro (Stock)</a></li>
|
||||
<li><a href="../antminer/X21#t21-stock">T21 (Stock)</a></li>
|
||||
<li><a href="../antminer/X21#s21-hydro-stock">S21 Hydro (Stock)</a></li>
|
||||
@@ -566,12 +563,6 @@ details {
|
||||
<li><a href="../avalonminer/A15X#avalon-1566-stock">Avalon 1566 (Stock)</a></li>
|
||||
</ul>
|
||||
</details>
|
||||
<details>
|
||||
<summary>Q Series:</summary>
|
||||
<ul>
|
||||
<li><a href="../avalonminer/Q#avalon-q-home-stock">Avalon Q Home (Stock)</a></li>
|
||||
</ul>
|
||||
</details>
|
||||
</ul>
|
||||
</details>
|
||||
<details>
|
||||
@@ -622,12 +613,6 @@ details {
|
||||
<li><a href="../goldshell/XBox#kd-box-pro-stock">KD Box Pro (Stock)</a></li>
|
||||
</ul>
|
||||
</details>
|
||||
<details>
|
||||
<summary>Byte Series:</summary>
|
||||
<ul>
|
||||
<li><a href="../goldshell/Byte#byte-stock">Byte (Stock)</a></li>
|
||||
</ul>
|
||||
</details>
|
||||
</ul>
|
||||
</details>
|
||||
<details>
|
||||
@@ -671,7 +656,6 @@ details {
|
||||
<li><a href="../antminer/X19#s19-xp-bos_1">S19 XP (BOS+)</a></li>
|
||||
<li><a href="../antminer/X19#s19-pro_1-hydro-bos_1">S19 Pro+ Hydro (BOS+)</a></li>
|
||||
<li><a href="../antminer/X19#t19-bos_1">T19 (BOS+)</a></li>
|
||||
<li><a href="../antminer/X19#s19-xp-hydro-bos_1">S19 XP Hydro (BOS+)</a></li>
|
||||
</ul>
|
||||
</details>
|
||||
<details>
|
||||
@@ -679,9 +663,6 @@ details {
|
||||
<ul>
|
||||
<li><a href="../antminer/X21#s21-bos_1">S21 (BOS+)</a></li>
|
||||
<li><a href="../antminer/X21#s21-pro-bos_1">S21 Pro (BOS+)</a></li>
|
||||
<li><a href="../antminer/X21#s21_1-bos_1">S21+ (BOS+)</a></li>
|
||||
<li><a href="../antminer/X21#s21_1-hydro-bos_1">S21+ Hydro (BOS+)</a></li>
|
||||
<li><a href="../antminer/X21#s21-hydro-bos_1">S21 Hydro (BOS+)</a></li>
|
||||
<li><a href="../antminer/X21#t21-bos_1">T21 (BOS+)</a></li>
|
||||
</ul>
|
||||
</details>
|
||||
@@ -710,12 +691,6 @@ details {
|
||||
<li><a href="../antminer/X7#l7-vnish">L7 (VNish)</a></li>
|
||||
</ul>
|
||||
</details>
|
||||
<details>
|
||||
<summary>X9 Series:</summary>
|
||||
<ul>
|
||||
<li><a href="../antminer/X9#l9-vnish">L9 (VNish)</a></li>
|
||||
</ul>
|
||||
</details>
|
||||
<details>
|
||||
<summary>X17 Series:</summary>
|
||||
<ul>
|
||||
@@ -731,15 +706,11 @@ details {
|
||||
<li><a href="../antminer/X19#s19-pro-vnish">S19 Pro (VNish)</a></li>
|
||||
<li><a href="../antminer/X19#s19j-vnish">S19j (VNish)</a></li>
|
||||
<li><a href="../antminer/X19#s19i-vnish">S19i (VNish)</a></li>
|
||||
<li><a href="../antminer/X19#s19-xp-vnish">S19 XP (VNish)</a></li>
|
||||
<li><a href="../antminer/X19#s19-xp-hydro-vnish">S19 XP Hydro (VNish)</a></li>
|
||||
<li><a href="../antminer/X19#s19j-pro-vnish">S19j Pro (VNish)</a></li>
|
||||
<li><a href="../antminer/X19#s19j-pro-vnish">S19j Pro (VNish)</a></li>
|
||||
<li><a href="../antminer/X19#s19j-pro-vnish">S19j Pro (VNish)</a></li>
|
||||
<li><a href="../antminer/X19#s19a-vnish">S19a (VNish)</a></li>
|
||||
<li><a href="../antminer/X19#s19-hydro-vnish">S19 Hydro (VNish)</a></li>
|
||||
<li><a href="../antminer/X19#s19a-pro-vnish">S19a Pro (VNish)</a></li>
|
||||
<li><a href="../antminer/X19#s19-pro-a-vnish">S19 Pro A (VNish)</a></li>
|
||||
<li><a href="../antminer/X19#s19-pro-hydro-vnish">S19 Pro Hydro (VNish)</a></li>
|
||||
<li><a href="../antminer/X19#s19k-pro-vnish">S19k Pro (VNish)</a></li>
|
||||
<li><a href="../antminer/X19#t19-vnish">T19 (VNish)</a></li>
|
||||
@@ -750,10 +721,6 @@ details {
|
||||
<ul>
|
||||
<li><a href="../antminer/X21#t21-vnish">T21 (VNish)</a></li>
|
||||
<li><a href="../antminer/X21#s21-vnish">S21 (VNish)</a></li>
|
||||
<li><a href="../antminer/X21#s21_1-vnish">S21+ (VNish)</a></li>
|
||||
<li><a href="../antminer/X21#s21_1-hydro-vnish">S21+ Hydro (VNish)</a></li>
|
||||
<li><a href="../antminer/X21#s21-pro-vnish">S21 Pro (VNish)</a></li>
|
||||
<li><a href="../antminer/X21#s21-hydro-vnish">S21 Hydro (VNish)</a></li>
|
||||
</ul>
|
||||
</details>
|
||||
</ul>
|
||||
@@ -948,12 +915,6 @@ details {
|
||||
<li><a href="../iceriver/KSX#ks5m-stock">KS5M (Stock)</a></li>
|
||||
</ul>
|
||||
</details>
|
||||
<details>
|
||||
<summary>ALX Series:</summary>
|
||||
<ul>
|
||||
<li><a href="../iceriver/ALX#al3-stock">AL3 (Stock)</a></li>
|
||||
</ul>
|
||||
</details>
|
||||
</ul>
|
||||
</details>
|
||||
<details>
|
||||
@@ -985,8 +946,6 @@ details {
|
||||
<summary>DGX Series:</summary>
|
||||
<ul>
|
||||
<li><a href="../elphapex/DGX#dg1_1-stock">DG1+ (Stock)</a></li>
|
||||
<li><a href="../elphapex/DGX#dg1-stock">DG1 (Stock)</a></li>
|
||||
<li><a href="../elphapex/DGX#dg1home-stock">DG1Home (Stock)</a></li>
|
||||
</ul>
|
||||
</details>
|
||||
</ul>
|
||||
|
||||
@@ -97,7 +97,6 @@ nav:
|
||||
- Innosilicon T3X: "miners/innosilicon/T3X.md"
|
||||
- Innosilicon A10X: "miners/innosilicon/A10X.md"
|
||||
- Innosilicon A11X: "miners/innosilicon/A11X.md"
|
||||
- Goldshell Byte: "miners/goldshell/Byte.md"
|
||||
- Goldshell X5: "miners/goldshell/X5.md"
|
||||
- Goldshell XMax: "miners/goldshell/XMax.md"
|
||||
- Goldshell XBox: "miners/goldshell/XBox.md"
|
||||
|
||||
@@ -247,11 +247,6 @@ class MinerConfig(BaseModel):
|
||||
"""Constructs a MinerConfig object from web configuration for Goldshell miners."""
|
||||
return cls(pools=PoolConfig.from_am_modern(web_conf))
|
||||
|
||||
@classmethod
|
||||
def from_goldshell_byte(cls, web_conf: dict) -> "MinerConfig":
|
||||
"""Constructs a MinerConfig object from web configuration for Goldshell Byte miners."""
|
||||
return cls(pools=PoolConfig.from_goldshell_byte(web_conf))
|
||||
|
||||
@classmethod
|
||||
def from_inno(cls, web_pools: list) -> "MinerConfig":
|
||||
"""Constructs a MinerConfig object from web configuration for Innosilicon miners."""
|
||||
@@ -288,17 +283,13 @@ class MinerConfig(BaseModel):
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def from_vnish(
|
||||
cls, web_settings: dict, web_presets: list[dict], web_perf_summary: dict
|
||||
) -> "MinerConfig":
|
||||
def from_vnish(cls, web_settings: dict, web_presets: list[dict]) -> "MinerConfig":
|
||||
"""Constructs a MinerConfig object from web settings for VNish miners."""
|
||||
return cls(
|
||||
pools=PoolConfig.from_vnish(web_settings),
|
||||
fan_mode=FanModeConfig.from_vnish(web_settings),
|
||||
temperature=TemperatureConfig.from_vnish(web_settings),
|
||||
mining_mode=MiningModeConfig.from_vnish(
|
||||
web_settings, web_presets, web_perf_summary
|
||||
),
|
||||
mining_mode=MiningModeConfig.from_vnish(web_settings, web_presets),
|
||||
)
|
||||
|
||||
@classmethod
|
||||
|
||||
@@ -412,18 +412,12 @@ class MiningModePreset(MinerConfigValue):
|
||||
|
||||
@classmethod
|
||||
def from_vnish(
|
||||
cls,
|
||||
web_overclock_settings: dict,
|
||||
web_presets: list[dict],
|
||||
web_perf_summary: dict,
|
||||
cls, web_overclock_settings: dict, web_presets: list[dict]
|
||||
) -> "MiningModePreset":
|
||||
active_preset = web_perf_summary.get("current_preset")
|
||||
|
||||
if active_preset is None:
|
||||
for preset in web_presets:
|
||||
if preset["name"] == web_overclock_settings["preset"]:
|
||||
active_preset = preset
|
||||
|
||||
active_preset = None
|
||||
for preset in web_presets:
|
||||
if preset["name"] == web_overclock_settings["preset"]:
|
||||
active_preset = preset
|
||||
return cls(
|
||||
active_preset=MiningPreset.from_vnish(active_preset),
|
||||
available_presets=[MiningPreset.from_vnish(p) for p in web_presets],
|
||||
@@ -709,9 +703,7 @@ class MiningModeConfig(MinerConfigOption):
|
||||
return cls.default()
|
||||
|
||||
@classmethod
|
||||
def from_vnish(
|
||||
cls, web_settings: dict, web_presets: list[dict], web_perf_summary: dict
|
||||
):
|
||||
def from_vnish(cls, web_settings: dict, web_presets: list[dict]):
|
||||
try:
|
||||
mode_settings = web_settings["miner"]["overclock"]
|
||||
except KeyError:
|
||||
@@ -720,9 +712,7 @@ class MiningModeConfig(MinerConfigOption):
|
||||
if mode_settings["preset"] == "disabled":
|
||||
return MiningModeManual.from_vnish(mode_settings)
|
||||
else:
|
||||
return MiningModePreset.from_vnish(
|
||||
mode_settings, web_presets, web_perf_summary
|
||||
)
|
||||
return MiningModePreset.from_vnish(mode_settings, web_presets)
|
||||
|
||||
@classmethod
|
||||
def from_boser(cls, grpc_miner_conf: dict):
|
||||
|
||||
@@ -631,16 +631,6 @@ class PoolConfig(MinerConfigValue):
|
||||
def from_goldshell(cls, web_pools: list) -> "PoolConfig":
|
||||
return cls(groups=[PoolGroup.from_goldshell(web_pools)])
|
||||
|
||||
@classmethod
|
||||
def from_goldshell_byte(cls, web_pools: list) -> "PoolConfig":
|
||||
return cls(
|
||||
groups=[
|
||||
PoolGroup.from_goldshell(g["pools"])
|
||||
for g in web_pools
|
||||
if len(g["pools"]) > 0
|
||||
]
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def from_inno(cls, web_pools: list) -> "PoolConfig":
|
||||
return cls(groups=[PoolGroup.from_inno(web_pools)])
|
||||
|
||||
@@ -70,7 +70,6 @@ class MinerData(BaseModel):
|
||||
errors: A list of errors on the miner.
|
||||
fault_light: Whether the fault light is on as a boolean.
|
||||
efficiency: Efficiency of the miner in J/TH (Watts per TH/s). Calculated automatically.
|
||||
efficiency_fract: Same as efficiency, but is not rounded to integer. Calculated automatically.
|
||||
is_mining: Whether the miner is mining.
|
||||
pools: A list of PoolMetrics instances, each representing metrics for a pool.
|
||||
"""
|
||||
@@ -294,7 +293,7 @@ class MinerData(BaseModel):
|
||||
@computed_field # type: ignore[misc]
|
||||
@property
|
||||
def efficiency_fract(self) -> float | None:
|
||||
return self._efficiency(2)
|
||||
self._efficiency(2)
|
||||
|
||||
def _efficiency(self, ndigits: int) -> float | None:
|
||||
if self.hashrate is None or self.wattage is None:
|
||||
@@ -302,7 +301,7 @@ class MinerData(BaseModel):
|
||||
try:
|
||||
return round(self.wattage / float(self.hashrate), ndigits)
|
||||
except ZeroDivisionError:
|
||||
return 0.0
|
||||
return 0
|
||||
|
||||
@computed_field # type: ignore[misc]
|
||||
@property
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
from .base import MinerAlgoType
|
||||
from .blake256 import Blake256Algo
|
||||
from .blockflow import BlockFlowAlgo
|
||||
from .eaglesong import EaglesongAlgo
|
||||
from .equihash import EquihashAlgo
|
||||
from .ethash import EtHashAlgo
|
||||
@@ -12,7 +11,6 @@ from .kheavyhash import KHeavyHashAlgo
|
||||
from .scrypt import ScryptAlgo
|
||||
from .sha256 import SHA256Algo
|
||||
from .x11 import X11Algo
|
||||
from .zksnark import ZkSnarkAlgo
|
||||
|
||||
|
||||
class MinerAlgo:
|
||||
@@ -26,5 +24,3 @@ class MinerAlgo:
|
||||
EAGLESONG = EaglesongAlgo
|
||||
ETHASH = EtHashAlgo
|
||||
EQUIHASH = EquihashAlgo
|
||||
BLOCKFLOW = BlockFlowAlgo
|
||||
ZKSNARK = ZkSnarkAlgo
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from .base import MinerAlgoType
|
||||
from .hashrate import BlockFlowHashRate
|
||||
from .hashrate.unit import BlockFlowUnit
|
||||
|
||||
|
||||
class BlockFlowAlgo(MinerAlgoType):
|
||||
hashrate: type[BlockFlowHashRate] = BlockFlowHashRate
|
||||
unit: type[BlockFlowUnit] = BlockFlowUnit
|
||||
|
||||
name = "BlockFlow"
|
||||
@@ -1,6 +1,5 @@
|
||||
from .base import AlgoHashRateType
|
||||
from .blake256 import Blake256HashRate
|
||||
from .blockflow import BlockFlowHashRate
|
||||
from .eaglesong import EaglesongHashRate
|
||||
from .equihash import EquihashHashRate
|
||||
from .ethash import EtHashHashRate
|
||||
@@ -10,7 +9,6 @@ from .kheavyhash import KHeavyHashHashRate
|
||||
from .scrypt import ScryptHashRate
|
||||
from .sha256 import SHA256HashRate
|
||||
from .x11 import X11HashRate
|
||||
from .zksnark import ZkSnarkHashRate
|
||||
|
||||
|
||||
class AlgoHashRate:
|
||||
@@ -24,5 +22,3 @@ class AlgoHashRate:
|
||||
EAGLESONG = EaglesongHashRate
|
||||
ETHASH = EtHashHashRate
|
||||
EQUIHASH = EquihashHashRate
|
||||
BLOCKFLOW = BlockFlowHashRate
|
||||
ZKSNARK = ZkSnarkHashRate
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing_extensions import Self
|
||||
|
||||
from pyasic.device.algorithm.hashrate.base import AlgoHashRateType
|
||||
from pyasic.device.algorithm.hashrate.unit.blockflow import BlockFlowUnit
|
||||
|
||||
from .unit import HashUnit
|
||||
|
||||
|
||||
class BlockFlowHashRate(AlgoHashRateType):
|
||||
rate: float
|
||||
unit: BlockFlowUnit = HashUnit.BLOCKFLOW.default
|
||||
|
||||
def into(self, other: BlockFlowUnit) -> Self:
|
||||
return self.__class__(
|
||||
rate=self.rate / (other.value / self.unit.value), unit=other
|
||||
)
|
||||
@@ -1,5 +1,4 @@
|
||||
from .blake256 import Blake256Unit
|
||||
from .blockflow import BlockFlowUnit
|
||||
from .eaglesong import EaglesongUnit
|
||||
from .equihash import EquihashUnit
|
||||
from .ethash import EtHashUnit
|
||||
@@ -9,7 +8,6 @@ from .kheavyhash import KHeavyHashUnit
|
||||
from .scrypt import ScryptUnit
|
||||
from .sha256 import SHA256Unit
|
||||
from .x11 import X11Unit
|
||||
from .zksnark import ZkSnarkUnit
|
||||
|
||||
|
||||
class HashUnit:
|
||||
@@ -23,5 +21,3 @@ class HashUnit:
|
||||
EAGLESONG = EaglesongUnit
|
||||
ETHASH = EtHashUnit
|
||||
EQUIHASH = EquihashUnit
|
||||
BLOCKFLOW = BlockFlowUnit
|
||||
ZKSNARK = ZkSnarkUnit
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from .base import AlgoHashRateUnitType
|
||||
|
||||
|
||||
class BlockFlowUnit(AlgoHashRateUnitType):
|
||||
H = 1
|
||||
KH = int(H) * 1000
|
||||
MH = int(KH) * 1000
|
||||
GH = int(MH) * 1000
|
||||
TH = int(GH) * 1000
|
||||
PH = int(TH) * 1000
|
||||
EH = int(PH) * 1000
|
||||
ZH = int(EH) * 1000
|
||||
|
||||
default = MH
|
||||
@@ -1,16 +0,0 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from .base import AlgoHashRateUnitType
|
||||
|
||||
|
||||
class ZkSnarkUnit(AlgoHashRateUnitType):
|
||||
H = 1
|
||||
KH = int(H) * 1000
|
||||
MH = int(KH) * 1000
|
||||
GH = int(MH) * 1000
|
||||
TH = int(GH) * 1000
|
||||
PH = int(TH) * 1000
|
||||
EH = int(PH) * 1000
|
||||
ZH = int(EH) * 1000
|
||||
|
||||
default = GH
|
||||
@@ -1,18 +0,0 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing_extensions import Self
|
||||
|
||||
from pyasic.device.algorithm.hashrate.base import AlgoHashRateType
|
||||
from pyasic.device.algorithm.hashrate.unit.zksnark import ZkSnarkUnit
|
||||
|
||||
from .unit import HashUnit
|
||||
|
||||
|
||||
class ZkSnarkHashRate(AlgoHashRateType):
|
||||
rate: float
|
||||
unit: ZkSnarkUnit = HashUnit.ZKSNARK.default
|
||||
|
||||
def into(self, other: ZkSnarkUnit) -> Self:
|
||||
return self.__class__(
|
||||
rate=self.rate / (other.value / self.unit.value), unit=other
|
||||
)
|
||||
@@ -1,12 +0,0 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from .base import MinerAlgoType
|
||||
from .hashrate import ZkSnarkHashRate
|
||||
from .hashrate.unit import ZkSnarkUnit
|
||||
|
||||
|
||||
class ZkSnarkAlgo(MinerAlgoType):
|
||||
hashrate: type[ZkSnarkHashRate] = ZkSnarkHashRate
|
||||
unit: type[ZkSnarkUnit] = ZkSnarkUnit
|
||||
|
||||
name = "zkSNARK"
|
||||
@@ -43,7 +43,6 @@ class AntminerModels(MinerModelType):
|
||||
S19jNoPIC = "S19j No PIC"
|
||||
S19ProPlus = "S19 Pro+"
|
||||
S19jPro = "S19j Pro"
|
||||
S19jPlus = "S19j+"
|
||||
S19jProNoPIC = "S19j Pro No PIC"
|
||||
S19jProPlus = "S19j Pro+"
|
||||
S19jProPlusNoPIC = "S19j Pro+ No PIC"
|
||||
@@ -55,7 +54,6 @@ class AntminerModels(MinerModelType):
|
||||
S19ProPlusHydro = "S19 Pro+ Hydro"
|
||||
S19KPro = "S19K Pro"
|
||||
S19kPro = "S19k Pro"
|
||||
S19ProA = "S19 Pro A"
|
||||
S19kProNoPIC = "S19k Pro No PIC"
|
||||
S19jXP = "S19j XP"
|
||||
T19 = "T19"
|
||||
@@ -65,7 +63,6 @@ class AntminerModels(MinerModelType):
|
||||
S21Pro = "S21 Pro"
|
||||
S21Hydro = "S21 Hydro"
|
||||
T21 = "T21"
|
||||
S19XPHydro = "S19 XP Hydro"
|
||||
|
||||
def __str__(self):
|
||||
return self.value
|
||||
@@ -456,7 +453,6 @@ class AvalonminerModels(MinerModelType):
|
||||
Avalon1566 = "Avalon 1566"
|
||||
AvalonNano3 = "Avalon Nano 3"
|
||||
AvalonNano3s = "Avalon Nano 3s"
|
||||
AvalonQHome = "Avalon Q Home"
|
||||
|
||||
def __str__(self):
|
||||
return self.value
|
||||
@@ -479,7 +475,6 @@ class GoldshellModels(MinerModelType):
|
||||
KDMax = "KD Max"
|
||||
KDBoxII = "KD Box II"
|
||||
KDBoxPro = "KD Box Pro"
|
||||
Byte = "Byte"
|
||||
|
||||
def __str__(self):
|
||||
return self.value
|
||||
@@ -537,7 +532,6 @@ class IceRiverModels(MinerModelType):
|
||||
KS5 = "KS5"
|
||||
KS5L = "KS5L"
|
||||
KS5M = "KS5M"
|
||||
AL3 = "AL3"
|
||||
|
||||
def __str__(self):
|
||||
return self.value
|
||||
@@ -563,9 +557,7 @@ class BraiinsModels(MinerModelType):
|
||||
|
||||
|
||||
class ElphapexModels(MinerModelType):
|
||||
DG1 = "DG1"
|
||||
DG1Plus = "DG1+"
|
||||
DG1Home = "DG1Home"
|
||||
|
||||
|
||||
class MinerModel:
|
||||
|
||||
@@ -25,9 +25,7 @@ from pyasic.miners.device.models import (
|
||||
S19i,
|
||||
S19j,
|
||||
S19jNoPIC,
|
||||
S19jPlus,
|
||||
S19jPro,
|
||||
S19jProPlus,
|
||||
S19jXP,
|
||||
S19KPro,
|
||||
S19Plus,
|
||||
@@ -82,10 +80,6 @@ class BMMinerS19jPro(AntminerModern, S19jPro):
|
||||
pass
|
||||
|
||||
|
||||
class BMMinerS19jPlus(AntminerModern, S19jPlus):
|
||||
pass
|
||||
|
||||
|
||||
class BMMinerS19L(AntminerModern, S19L):
|
||||
pass
|
||||
|
||||
@@ -108,7 +102,3 @@ class BMMinerS19KPro(AntminerModern, S19KPro):
|
||||
|
||||
class BMMinerS19jXP(AntminerModern, S19jXP):
|
||||
pass
|
||||
|
||||
|
||||
class BMMinerS19jProPlus(AntminerModern, S19jProPlus):
|
||||
pass
|
||||
|
||||
@@ -22,9 +22,7 @@ from .S19 import (
|
||||
BMMinerS19i,
|
||||
BMMinerS19j,
|
||||
BMMinerS19jNoPIC,
|
||||
BMMinerS19jPlus,
|
||||
BMMinerS19jPro,
|
||||
BMMinerS19jProPlus,
|
||||
BMMinerS19jXP,
|
||||
BMMinerS19KPro,
|
||||
BMMinerS19L,
|
||||
|
||||
@@ -30,7 +30,6 @@ from pyasic.miners.device.models import (
|
||||
S19Plus,
|
||||
S19Pro,
|
||||
S19ProPlusHydro,
|
||||
S19XPHydro,
|
||||
)
|
||||
|
||||
|
||||
@@ -88,7 +87,3 @@ class BOSMinerS19XP(BOSer, S19XP):
|
||||
|
||||
class BOSMinerS19ProPlusHydro(BOSer, S19ProPlusHydro):
|
||||
pass
|
||||
|
||||
|
||||
class BOSMinerS19XPHydro(BOSer, S19XPHydro):
|
||||
pass
|
||||
|
||||
@@ -29,6 +29,5 @@ from .S19 import (
|
||||
BOSMinerS19Pro,
|
||||
BOSMinerS19ProPlusHydro,
|
||||
BOSMinerS19XP,
|
||||
BOSMinerS19XPHydro,
|
||||
)
|
||||
from .T19 import BOSMinerT19
|
||||
|
||||
@@ -15,40 +15,12 @@
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
from pyasic.miners.backends import BOSer
|
||||
from pyasic.miners.device.models import S21, S21Hydro, S21Plus, S21PlusHydro, S21Pro
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# 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.device.models import S21, S21Pro
|
||||
|
||||
|
||||
class BOSMinerS21(BOSer, S21):
|
||||
pass
|
||||
|
||||
|
||||
class BOSMinerS21Plus(BOSer, S21Plus):
|
||||
pass
|
||||
|
||||
|
||||
class BOSMinerS21PlusHydro(BOSer, S21PlusHydro):
|
||||
pass
|
||||
|
||||
|
||||
class BOSMinerS21Pro(BOSer, S21Pro):
|
||||
pass
|
||||
|
||||
|
||||
class BOSMinerS21Hydro(BOSer, S21Hydro):
|
||||
pass
|
||||
|
||||
@@ -14,11 +14,5 @@
|
||||
# limitations under the License. -
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
from .S21 import (
|
||||
BOSMinerS21,
|
||||
BOSMinerS21Hydro,
|
||||
BOSMinerS21Plus,
|
||||
BOSMinerS21PlusHydro,
|
||||
BOSMinerS21Pro,
|
||||
)
|
||||
from .S21 import BOSMinerS21, BOSMinerS21Pro
|
||||
from .T21 import BOSMinerT21
|
||||
|
||||
@@ -20,16 +20,13 @@ from pyasic.miners.device.models import (
|
||||
S19XP,
|
||||
S19a,
|
||||
S19aPro,
|
||||
S19Hydro,
|
||||
S19i,
|
||||
S19j,
|
||||
S19jPro,
|
||||
S19kPro,
|
||||
S19NoPIC,
|
||||
S19Pro,
|
||||
S19ProA,
|
||||
S19ProHydro,
|
||||
S19XPHydro,
|
||||
)
|
||||
|
||||
|
||||
@@ -45,18 +42,10 @@ class VNishS19Pro(VNish, S19Pro):
|
||||
pass
|
||||
|
||||
|
||||
class VNishS19Hydro(VNish, S19Hydro):
|
||||
pass
|
||||
|
||||
|
||||
class VNishS19XP(VNish, S19XP):
|
||||
pass
|
||||
|
||||
|
||||
class VNishS19XPHydro(VNish, S19XPHydro):
|
||||
pass
|
||||
|
||||
|
||||
class VNishS19a(VNish, S19a):
|
||||
pass
|
||||
|
||||
@@ -65,10 +54,6 @@ class VNishS19aPro(VNish, S19aPro):
|
||||
pass
|
||||
|
||||
|
||||
class VNishS19ProA(VNish, S19ProA):
|
||||
pass
|
||||
|
||||
|
||||
class VNishS19i(VNish, S19i):
|
||||
pass
|
||||
|
||||
@@ -87,7 +72,3 @@ class VNishS19ProHydro(VNish, S19ProHydro):
|
||||
|
||||
class VNishS19kPro(VNish, S19kPro):
|
||||
pass
|
||||
|
||||
|
||||
class VNishS19ProA(VNish, S19ProA):
|
||||
pass
|
||||
|
||||
@@ -18,16 +18,13 @@ from .S19 import (
|
||||
VNishS19,
|
||||
VNishS19a,
|
||||
VNishS19aPro,
|
||||
VNishS19Hydro,
|
||||
VNishS19i,
|
||||
VNishS19j,
|
||||
VNishS19jPro,
|
||||
VNishS19kPro,
|
||||
VNishS19NoPIC,
|
||||
VNishS19Pro,
|
||||
VNishS19ProA,
|
||||
VNishS19ProHydro,
|
||||
VNishS19XP,
|
||||
VNishS19XPHydro,
|
||||
)
|
||||
from .T19 import VNishT19
|
||||
|
||||
@@ -15,24 +15,8 @@
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
from pyasic.miners.backends import VNish
|
||||
from pyasic.miners.device.models import S21, S21Hydro, S21Plus, S21PlusHydro, S21Pro
|
||||
from pyasic.miners.device.models import S21
|
||||
|
||||
|
||||
class VNishS21(VNish, S21):
|
||||
pass
|
||||
|
||||
|
||||
class VNishS21Plus(VNish, S21Plus):
|
||||
pass
|
||||
|
||||
|
||||
class VNishS21PlusHydro(VNish, S21PlusHydro):
|
||||
pass
|
||||
|
||||
|
||||
class VNishS21Pro(VNish, S21Pro):
|
||||
pass
|
||||
|
||||
|
||||
class VNishS21Hydro(VNish, S21Hydro):
|
||||
pass
|
||||
|
||||
@@ -14,11 +14,5 @@
|
||||
# limitations under the License. -
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
from .S21 import (
|
||||
VNishS21,
|
||||
VNishS21Hydro,
|
||||
VNishS21Plus,
|
||||
VNishS21PlusHydro,
|
||||
VNishS21Pro,
|
||||
)
|
||||
from .S21 import VNishS21
|
||||
from .T21 import VNishT21
|
||||
|
||||
@@ -18,5 +18,5 @@ from pyasic.miners.backends import VNish
|
||||
from pyasic.miners.device.models import L3Plus
|
||||
|
||||
|
||||
class VNishL3Plus(VNish, L3Plus):
|
||||
class VnishL3Plus(VNish, L3Plus):
|
||||
pass
|
||||
|
||||
@@ -14,4 +14,4 @@
|
||||
# limitations under the License. -
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
from .L3 import VNishL3Plus
|
||||
from .L3 import VnishL3Plus
|
||||
|
||||
@@ -18,5 +18,5 @@ from pyasic.miners.backends import VNish
|
||||
from pyasic.miners.device.models import L7
|
||||
|
||||
|
||||
class VNishL7(VNish, L7):
|
||||
class VnishL7(VNish, L7):
|
||||
pass
|
||||
|
||||
@@ -14,4 +14,4 @@
|
||||
# limitations under the License. -
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
from .L7 import VNishL7
|
||||
from .L7 import VnishL7
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
# ------------------------------------------------------------------------------
|
||||
# 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.device.models import L9
|
||||
|
||||
|
||||
class VNishL9(VNish, L9):
|
||||
pass
|
||||
@@ -1,17 +0,0 @@
|
||||
# ------------------------------------------------------------------------------
|
||||
# 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 .L9 import VNishL9
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
from .X3 import *
|
||||
from .X7 import *
|
||||
from .X9 import *
|
||||
from .X17 import *
|
||||
from .X19 import *
|
||||
from .X21 import *
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
# ------------------------------------------------------------------------------
|
||||
# Copyright 2025 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 AvalonQHome
|
||||
|
||||
|
||||
class CGMinerAvalonQHome(AvalonMiner, AvalonQHome):
|
||||
pass
|
||||
@@ -1 +0,0 @@
|
||||
from .Q import CGMinerAvalonQHome
|
||||
@@ -22,4 +22,3 @@ from .A11X import *
|
||||
from .A12X import *
|
||||
from .A15X import *
|
||||
from .nano import *
|
||||
from .Q import *
|
||||
|
||||
@@ -49,31 +49,31 @@ AVALON_NANO_DATA_LOC = DataLocations(
|
||||
),
|
||||
str(DataOptions.EXPECTED_HASHRATE): DataFunction(
|
||||
"_get_expected_hashrate",
|
||||
[RPCAPICommand("rpc_estats", "estats")],
|
||||
[RPCAPICommand("rpc_stats", "stats")],
|
||||
),
|
||||
str(DataOptions.HASHBOARDS): DataFunction(
|
||||
"_get_hashboards",
|
||||
[RPCAPICommand("rpc_estats", "estats")],
|
||||
[RPCAPICommand("rpc_stats", "stats")],
|
||||
),
|
||||
str(DataOptions.ENVIRONMENT_TEMP): DataFunction(
|
||||
"_get_env_temp",
|
||||
[RPCAPICommand("rpc_estats", "estats")],
|
||||
[RPCAPICommand("rpc_stats", "stats")],
|
||||
),
|
||||
str(DataOptions.WATTAGE_LIMIT): DataFunction(
|
||||
"_get_wattage_limit",
|
||||
[RPCAPICommand("rpc_estats", "estats")],
|
||||
[RPCAPICommand("rpc_stats", "stats")],
|
||||
),
|
||||
str(DataOptions.WATTAGE): DataFunction(
|
||||
"_get_wattage",
|
||||
[RPCAPICommand("rpc_estats", "estats")],
|
||||
[RPCAPICommand("rpc_stats", "stats")],
|
||||
),
|
||||
str(DataOptions.FANS): DataFunction(
|
||||
"_get_fans",
|
||||
[RPCAPICommand("rpc_estats", "estats")],
|
||||
[RPCAPICommand("rpc_stats", "stats")],
|
||||
),
|
||||
str(DataOptions.FAULT_LIGHT): DataFunction(
|
||||
"_get_fault_light",
|
||||
[RPCAPICommand("rpc_estats", "estats")],
|
||||
[RPCAPICommand("rpc_stats", "stats")],
|
||||
),
|
||||
str(DataOptions.UPTIME): DataFunction(
|
||||
"_get_uptime",
|
||||
@@ -102,35 +102,35 @@ AVALON_NANO3S_DATA_LOC = DataLocations(
|
||||
),
|
||||
str(DataOptions.HASHRATE): DataFunction(
|
||||
"_get_hashrate",
|
||||
[RPCAPICommand("rpc_estats", "estats")],
|
||||
[RPCAPICommand("rpc_stats", "stats")],
|
||||
),
|
||||
str(DataOptions.EXPECTED_HASHRATE): DataFunction(
|
||||
"_get_expected_hashrate",
|
||||
[RPCAPICommand("rpc_estats", "estats")],
|
||||
[RPCAPICommand("rpc_stats", "stats")],
|
||||
),
|
||||
str(DataOptions.HASHBOARDS): DataFunction(
|
||||
"_get_hashboards",
|
||||
[RPCAPICommand("rpc_estats", "estats")],
|
||||
[RPCAPICommand("rpc_stats", "stats")],
|
||||
),
|
||||
str(DataOptions.ENVIRONMENT_TEMP): DataFunction(
|
||||
"_get_env_temp",
|
||||
[RPCAPICommand("rpc_estats", "estats")],
|
||||
[RPCAPICommand("rpc_stats", "stats")],
|
||||
),
|
||||
str(DataOptions.WATTAGE_LIMIT): DataFunction(
|
||||
"_get_wattage_limit",
|
||||
[RPCAPICommand("rpc_estats", "estats")],
|
||||
[RPCAPICommand("rpc_stats", "stats")],
|
||||
),
|
||||
str(DataOptions.WATTAGE): DataFunction(
|
||||
"_get_wattage",
|
||||
[RPCAPICommand("rpc_estats", "estats")],
|
||||
[RPCAPICommand("rpc_stats", "stats")],
|
||||
),
|
||||
str(DataOptions.FANS): DataFunction(
|
||||
"_get_fans",
|
||||
[RPCAPICommand("rpc_estats", "estats")],
|
||||
[RPCAPICommand("rpc_stats", "stats")],
|
||||
),
|
||||
str(DataOptions.FAULT_LIGHT): DataFunction(
|
||||
"_get_fault_light",
|
||||
[RPCAPICommand("rpc_estats", "estats")],
|
||||
[RPCAPICommand("rpc_stats", "stats")],
|
||||
),
|
||||
str(DataOptions.UPTIME): DataFunction(
|
||||
"_get_uptime",
|
||||
@@ -170,58 +170,58 @@ class CGMinerAvalonNano3s(AvalonMiner, AvalonNano3s):
|
||||
|
||||
data_locations = AVALON_NANO3S_DATA_LOC
|
||||
|
||||
async def _get_wattage(self, rpc_estats: dict = None) -> Optional[int]:
|
||||
if rpc_estats is None:
|
||||
async def _get_wattage(self, rpc_stats: dict = None) -> Optional[int]:
|
||||
if rpc_stats is None:
|
||||
try:
|
||||
rpc_estats = await self.rpc.estats()
|
||||
rpc_stats = await self.rpc.stats()
|
||||
except APIError:
|
||||
pass
|
||||
|
||||
if rpc_estats is not None:
|
||||
if rpc_stats is not None:
|
||||
try:
|
||||
unparsed_estats = rpc_estats["STATS"][0]["MM ID0"]
|
||||
parsed_estats = self.parse_estats(unparsed_estats)
|
||||
return int(parsed_estats["PS"][6])
|
||||
unparsed_stats = rpc_stats["STATS"][0]["MM ID0"]
|
||||
parsed_stats = self.parse_stats(unparsed_stats)
|
||||
return int(parsed_stats["PS"][6])
|
||||
except (IndexError, KeyError, ValueError, TypeError):
|
||||
pass
|
||||
|
||||
async def _get_hashrate(self, rpc_estats: dict = None) -> Optional[AlgoHashRate]:
|
||||
if rpc_estats is None:
|
||||
async def _get_hashrate(self, rpc_stats: dict = None) -> Optional[AlgoHashRate]:
|
||||
if rpc_stats is None:
|
||||
try:
|
||||
rpc_estats = await self.rpc.estats()
|
||||
rpc_stats = await self.rpc.stats()
|
||||
except APIError:
|
||||
pass
|
||||
|
||||
if rpc_estats is not None:
|
||||
if rpc_stats is not None:
|
||||
try:
|
||||
unparsed_estats = rpc_estats["STATS"][0]["MM ID0"]
|
||||
parsed_estats = self.parse_estats(unparsed_estats)
|
||||
unparsed_stats = rpc_stats["STATS"][0]["MM ID0"]
|
||||
parsed_stats = self.parse_stats(unparsed_stats)
|
||||
return self.algo.hashrate(
|
||||
rate=float(parsed_estats["GHSspd"]), unit=self.algo.unit.GH
|
||||
rate=float(parsed_stats["GHSspd"][0]), unit=self.algo.unit.GH
|
||||
).into(self.algo.unit.default)
|
||||
except (IndexError, KeyError, ValueError, TypeError):
|
||||
pass
|
||||
|
||||
async def _get_hashboards(self, rpc_estats: dict = None) -> List[HashBoard]:
|
||||
hashboards = await AvalonMiner._get_hashboards(self, rpc_estats)
|
||||
async def _get_hashboards(self, rpc_stats: dict = None) -> List[HashBoard]:
|
||||
hashboards = await AvalonMiner._get_hashboards(self, rpc_stats)
|
||||
|
||||
if rpc_estats is None:
|
||||
if rpc_stats is None:
|
||||
try:
|
||||
rpc_estats = await self.rpc.estats()
|
||||
rpc_stats = await self.rpc.stats()
|
||||
except APIError:
|
||||
pass
|
||||
|
||||
if rpc_estats is not None:
|
||||
if rpc_stats is not None:
|
||||
|
||||
try:
|
||||
unparsed_estats = rpc_estats["STATS"][0]["MM ID0"]
|
||||
parsed_estats = self.parse_estats(unparsed_estats)
|
||||
unparsed_stats = rpc_stats["STATS"][0]["MM ID0"]
|
||||
parsed_stats = self.parse_stats(unparsed_stats)
|
||||
except (IndexError, KeyError, ValueError, TypeError):
|
||||
return hashboards
|
||||
|
||||
for board in range(len(hashboards)):
|
||||
try:
|
||||
board_hr = parsed_estats["GHSspd"][board]
|
||||
board_hr = parsed_stats["GHSspd"][board]
|
||||
hashboards[board].hashrate = self.algo.hashrate(
|
||||
rate=float(board_hr), unit=self.algo.unit.GH
|
||||
).into(self.algo.unit.default)
|
||||
|
||||
@@ -13,9 +13,8 @@
|
||||
# See the License for the specific language governing permissions and -
|
||||
# limitations under the License. -
|
||||
# ------------------------------------------------------------------------------
|
||||
import copy
|
||||
|
||||
import re
|
||||
import time
|
||||
from typing import List, Optional
|
||||
|
||||
from pyasic.data import Fan, HashBoard
|
||||
@@ -23,7 +22,6 @@ from pyasic.device.algorithm import AlgoHashRate
|
||||
from pyasic.errors import APIError
|
||||
from pyasic.miners.backends.cgminer import CGMiner
|
||||
from pyasic.miners.data import DataFunction, DataLocations, DataOptions, RPCAPICommand
|
||||
from pyasic.rpc.avalonminer import AvalonMinerRPCAPI
|
||||
|
||||
AVALON_DATA_LOC = DataLocations(
|
||||
**{
|
||||
@@ -45,31 +43,31 @@ AVALON_DATA_LOC = DataLocations(
|
||||
),
|
||||
str(DataOptions.EXPECTED_HASHRATE): DataFunction(
|
||||
"_get_expected_hashrate",
|
||||
[RPCAPICommand("rpc_estats", "estats")],
|
||||
[RPCAPICommand("rpc_stats", "stats")],
|
||||
),
|
||||
str(DataOptions.HASHBOARDS): DataFunction(
|
||||
"_get_hashboards",
|
||||
[RPCAPICommand("rpc_estats", "estats")],
|
||||
[RPCAPICommand("rpc_stats", "stats")],
|
||||
),
|
||||
str(DataOptions.ENVIRONMENT_TEMP): DataFunction(
|
||||
"_get_env_temp",
|
||||
[RPCAPICommand("rpc_estats", "estats")],
|
||||
[RPCAPICommand("rpc_stats", "stats")],
|
||||
),
|
||||
str(DataOptions.WATTAGE_LIMIT): DataFunction(
|
||||
"_get_wattage_limit",
|
||||
[RPCAPICommand("rpc_estats", "estats")],
|
||||
[RPCAPICommand("rpc_stats", "stats")],
|
||||
),
|
||||
str(DataOptions.WATTAGE): DataFunction(
|
||||
"_get_wattage",
|
||||
[RPCAPICommand("rpc_estats", "estats")],
|
||||
[RPCAPICommand("rpc_stats", "stats")],
|
||||
),
|
||||
str(DataOptions.FANS): DataFunction(
|
||||
"_get_fans",
|
||||
[RPCAPICommand("rpc_estats", "estats")],
|
||||
[RPCAPICommand("rpc_stats", "stats")],
|
||||
),
|
||||
str(DataOptions.FAULT_LIGHT): DataFunction(
|
||||
"_get_fault_light",
|
||||
[RPCAPICommand("rpc_estats", "estats")],
|
||||
[RPCAPICommand("rpc_stats", "stats")],
|
||||
),
|
||||
str(DataOptions.UPTIME): DataFunction(
|
||||
"_get_uptime",
|
||||
@@ -86,9 +84,6 @@ AVALON_DATA_LOC = DataLocations(
|
||||
class AvalonMiner(CGMiner):
|
||||
"""Handler for Avalon Miners"""
|
||||
|
||||
_rpc_cls = AvalonMinerRPCAPI
|
||||
rpc: AvalonMinerRPCAPI
|
||||
|
||||
data_locations = AVALON_DATA_LOC
|
||||
|
||||
async def fault_light_on(self) -> bool:
|
||||
@@ -139,94 +134,45 @@ class AvalonMiner(CGMiner):
|
||||
return False
|
||||
return False
|
||||
|
||||
async def stop_mining(self) -> bool:
|
||||
try:
|
||||
# Shut off 5 seconds from now
|
||||
timestamp = int(time.time()) + 5
|
||||
data = await self.rpc.ascset(0, f"softoff", f"1:{timestamp}")
|
||||
except APIError:
|
||||
return False
|
||||
if "success" in data["STATUS"][0]["Msg"]:
|
||||
return True
|
||||
return False
|
||||
|
||||
async def resume_mining(self) -> bool:
|
||||
try:
|
||||
# Shut off 5 seconds from now
|
||||
timestamp = int(time.time()) + 5
|
||||
data = await self.rpc.ascset(0, f"softon", f"1:{timestamp}")
|
||||
except APIError:
|
||||
return False
|
||||
if "success" in data["STATUS"][0]["Msg"]:
|
||||
return True
|
||||
return False
|
||||
|
||||
@staticmethod
|
||||
def parse_estats(data):
|
||||
# Deep copy to preserve original structure
|
||||
new_data = copy.deepcopy(data)
|
||||
|
||||
def convert_value(val, key):
|
||||
val = val.strip()
|
||||
|
||||
if key == "SYSTEMSTATU":
|
||||
return val
|
||||
|
||||
if " " in val:
|
||||
parts = val.split()
|
||||
result = []
|
||||
for part in parts:
|
||||
if part.isdigit():
|
||||
result.append(int(part))
|
||||
else:
|
||||
try:
|
||||
result.append(float(part))
|
||||
except ValueError:
|
||||
result.append(part)
|
||||
return result
|
||||
else:
|
||||
if val.isdigit():
|
||||
return int(val)
|
||||
def parse_stats(stats):
|
||||
_stats_items = re.findall(".+?\\[*?]", stats)
|
||||
stats_items = []
|
||||
stats_dict = {}
|
||||
for item in _stats_items:
|
||||
if ": " in item:
|
||||
data = item.replace("]", "").split("[")
|
||||
data_list = [i.split(": ") for i in data[1].strip().split(", ")]
|
||||
data_dict = {}
|
||||
try:
|
||||
return float(val)
|
||||
for key, val in [tuple(item) for item in data_list]:
|
||||
data_dict[key] = val
|
||||
except ValueError:
|
||||
return val
|
||||
# --avalon args
|
||||
for arg_item in data_list:
|
||||
item_data = arg_item[0].split(" ")
|
||||
for idx, val in enumerate(item_data):
|
||||
if idx % 2 == 0 or idx == 0:
|
||||
data_dict[val] = item_data[idx + 1]
|
||||
|
||||
def parse_info_block(info_str):
|
||||
pattern = re.compile(r"(\w+)\[([^\]]*)\]")
|
||||
return {
|
||||
key: convert_value(val, key) for key, val in pattern.findall(info_str)
|
||||
}
|
||||
raw_data = [data[0].strip(), data_dict]
|
||||
else:
|
||||
raw_data = [
|
||||
value
|
||||
for value in item.replace("[", " ")
|
||||
.replace("]", " ")
|
||||
.split(" ")[:-1]
|
||||
if value != ""
|
||||
]
|
||||
if len(raw_data) == 1:
|
||||
raw_data.append("")
|
||||
if raw_data[0] == "":
|
||||
raw_data = raw_data[1:]
|
||||
|
||||
for stat in new_data.get("STATS", []):
|
||||
keys_to_replace = {}
|
||||
stats_dict[raw_data[0]] = raw_data[1:]
|
||||
stats_items.append(raw_data)
|
||||
|
||||
for key, value in stat.items():
|
||||
if "MM" in key:
|
||||
# Normalize key by removing suffix after colon
|
||||
norm_key = key.split(":")[0]
|
||||
|
||||
mm_data = value
|
||||
if not isinstance(mm_data, str):
|
||||
continue
|
||||
if mm_data.startswith("'STATS':"):
|
||||
mm_data = mm_data[len("'STATS':") :]
|
||||
keys_to_replace[norm_key] = parse_info_block(mm_data)
|
||||
|
||||
elif key == "HBinfo":
|
||||
match = re.search(r"'(\w+)':\{(.+)\}", value)
|
||||
if match:
|
||||
hb_key = match.group(1)
|
||||
hb_data = match.group(2)
|
||||
keys_to_replace[key] = {hb_key: parse_info_block(hb_data)}
|
||||
|
||||
# Remove old keys and insert parsed versions
|
||||
for k in list(stat.keys()):
|
||||
if "MM" in k or k == "HBinfo":
|
||||
del stat[k]
|
||||
stat.update(keys_to_replace)
|
||||
|
||||
return new_data
|
||||
return stats_dict
|
||||
|
||||
##################################################
|
||||
### DATA GATHERING FUNCTIONS (get_{some_data}) ###
|
||||
@@ -265,7 +211,7 @@ class AvalonMiner(CGMiner):
|
||||
except (KeyError, IndexError, ValueError, TypeError):
|
||||
pass
|
||||
|
||||
async def _get_hashboards(self, rpc_estats: dict = None) -> List[HashBoard]:
|
||||
async def _get_hashboards(self, rpc_stats: dict = None) -> List[HashBoard]:
|
||||
if self.expected_hashboards is None:
|
||||
return []
|
||||
|
||||
@@ -274,202 +220,164 @@ class AvalonMiner(CGMiner):
|
||||
for i in range(self.expected_hashboards)
|
||||
]
|
||||
|
||||
if rpc_estats is None:
|
||||
if rpc_stats is None:
|
||||
try:
|
||||
rpc_estats = await self.rpc.estats()
|
||||
rpc_stats = await self.rpc.stats()
|
||||
except APIError:
|
||||
pass
|
||||
|
||||
if rpc_estats is not None:
|
||||
if rpc_stats is not None:
|
||||
try:
|
||||
parsed_estats = self.parse_estats(rpc_estats)
|
||||
unparsed_stats = rpc_stats["STATS"][0]["MM ID0"]
|
||||
parsed_stats = self.parse_stats(unparsed_stats)
|
||||
except (IndexError, KeyError, ValueError, TypeError):
|
||||
return hashboards
|
||||
|
||||
for board in range(self.expected_hashboards):
|
||||
|
||||
try:
|
||||
board_hr = parsed_estats["STATS"][0]["MM ID0"]["MGHS"]
|
||||
if isinstance(board_hr, list):
|
||||
hashboards[board].hashrate = self.algo.hashrate(
|
||||
rate=float(board_hr[board]), unit=self.algo.unit.GH
|
||||
).into(self.algo.unit.default)
|
||||
else:
|
||||
hashboards[board].hashrate = self.algo.hashrate(
|
||||
rate=float(board_hr), unit=self.algo.unit.GH
|
||||
).into(self.algo.unit.default)
|
||||
|
||||
hashboards[board].chip_temp = int(parsed_stats["MTmax"][board])
|
||||
except LookupError:
|
||||
pass
|
||||
|
||||
try:
|
||||
hashboards[board].chip_temp = int(
|
||||
parsed_estats["STATS"][0]["MM ID0"]["MTmax"][board]
|
||||
)
|
||||
board_hr = parsed_stats["MGHS"][board]
|
||||
hashboards[board].hashrate = self.algo.hashrate(
|
||||
rate=float(board_hr), unit=self.algo.unit.GH
|
||||
).into(self.algo.unit.default)
|
||||
except LookupError:
|
||||
try:
|
||||
hashboards[board].chip_temp = int(
|
||||
parsed_estats["STATS"][0]["MM ID0"]["Tmax"]
|
||||
)
|
||||
except LookupError:
|
||||
pass
|
||||
pass
|
||||
|
||||
try:
|
||||
hashboards[board].temp = int(
|
||||
parsed_estats["STATS"][0]["MM ID0"]["MTmax"][board]
|
||||
)
|
||||
hashboards[board].temp = int(parsed_stats["MTavg"][board])
|
||||
except LookupError:
|
||||
try:
|
||||
hashboards[board].temp = int(
|
||||
parsed_estats["STATS"][0]["MM ID0"]["Tavg"]
|
||||
)
|
||||
except LookupError:
|
||||
pass
|
||||
pass
|
||||
|
||||
try:
|
||||
hashboards[board].inlet_temp = int(
|
||||
parsed_estats["STATS"][0]["MM ID0"]["MTavg"][board]
|
||||
)
|
||||
except LookupError:
|
||||
try:
|
||||
hashboards[board].inlet_temp = int(
|
||||
parsed_estats["STATS"][0]["MM ID0"]["HBITemp"]
|
||||
)
|
||||
except LookupError:
|
||||
pass
|
||||
|
||||
try:
|
||||
hashboards[board].outlet_temp = int(
|
||||
parsed_estats["STATS"][0]["MM ID0"]["MTmax"][board]
|
||||
)
|
||||
except LookupError:
|
||||
try:
|
||||
hashboards[board].outlet_temp = int(
|
||||
parsed_estats["STATS"][0]["MM ID0"]["HBOTemp"]
|
||||
)
|
||||
except LookupError:
|
||||
pass
|
||||
|
||||
try:
|
||||
chip_data = parsed_estats["STATS"][0]["MM ID0"][f"PVT_T{board}"]
|
||||
chip_data = parsed_stats[f"PVT_T{board}"]
|
||||
hashboards[board].missing = False
|
||||
if chip_data:
|
||||
hashboards[board].chips = len(
|
||||
[item for item in chip_data if not item == "0"]
|
||||
)
|
||||
except LookupError:
|
||||
try:
|
||||
chip_data = parsed_estats["STATS"][0]["HBinfo"][f"HB{board}"][
|
||||
f"PVT_T{board}"
|
||||
]
|
||||
hashboards[board].missing = False
|
||||
if chip_data:
|
||||
hashboards[board].chips = len(
|
||||
[item for item in chip_data if not item == "0"]
|
||||
)
|
||||
except LookupError:
|
||||
pass
|
||||
pass
|
||||
|
||||
return hashboards
|
||||
|
||||
async def _get_expected_hashrate(
|
||||
self, rpc_estats: dict = None
|
||||
self, rpc_stats: dict = None
|
||||
) -> Optional[AlgoHashRate]:
|
||||
if rpc_estats is None:
|
||||
if rpc_stats is None:
|
||||
try:
|
||||
rpc_estats = await self.rpc.estats()
|
||||
rpc_stats = await self.rpc.stats()
|
||||
except APIError:
|
||||
pass
|
||||
|
||||
if rpc_estats is not None:
|
||||
if rpc_stats is not None:
|
||||
try:
|
||||
parsed_estats = self.parse_estats(rpc_estats)["STATS"][0]["MM ID0"]
|
||||
unparsed_stats = rpc_stats["STATS"][0]["MM ID0"]
|
||||
parsed_stats = self.parse_stats(unparsed_stats)
|
||||
return self.algo.hashrate(
|
||||
rate=float(parsed_estats["GHSmm"]), unit=self.algo.unit.GH
|
||||
rate=float(parsed_stats["GHSmm"][0]), unit=self.algo.unit.GH
|
||||
).into(self.algo.unit.default)
|
||||
except (IndexError, KeyError, ValueError, TypeError):
|
||||
pass
|
||||
|
||||
async def _get_env_temp(self, rpc_estats: dict = None) -> Optional[float]:
|
||||
if rpc_estats is None:
|
||||
async def _get_env_temp(self, rpc_stats: dict = None) -> Optional[float]:
|
||||
if rpc_stats is None:
|
||||
try:
|
||||
rpc_estats = await self.rpc.estats()
|
||||
rpc_stats = await self.rpc.stats()
|
||||
except APIError:
|
||||
pass
|
||||
|
||||
if rpc_estats is not None:
|
||||
if rpc_stats is not None:
|
||||
try:
|
||||
parsed_estats = self.parse_estats(rpc_estats)["STATS"][0]["MM ID0"]
|
||||
return float(parsed_estats["Temp"])
|
||||
unparsed_stats = rpc_stats["STATS"][0]["MM ID0"]
|
||||
parsed_stats = self.parse_stats(unparsed_stats)
|
||||
return float(parsed_stats["Temp"][0])
|
||||
except (IndexError, KeyError, ValueError, TypeError):
|
||||
pass
|
||||
|
||||
async def _get_wattage_limit(self, rpc_estats: dict = None) -> Optional[int]:
|
||||
if rpc_estats is None:
|
||||
async def _get_wattage_limit(self, rpc_stats: dict = None) -> Optional[int]:
|
||||
if rpc_stats is None:
|
||||
try:
|
||||
rpc_estats = await self.rpc.estats()
|
||||
rpc_stats = await self.rpc.stats()
|
||||
except APIError:
|
||||
pass
|
||||
|
||||
if rpc_estats is not None:
|
||||
if rpc_stats is not None:
|
||||
try:
|
||||
parsed_estats = self.parse_estats(rpc_estats)["STATS"][0]["MM ID0"]
|
||||
return int(parsed_estats["MPO"])
|
||||
unparsed_stats = rpc_stats["STATS"][0]["MM ID0"]
|
||||
parsed_stats = self.parse_stats(unparsed_stats)
|
||||
return int(parsed_stats["MPO"][0])
|
||||
except (IndexError, KeyError, ValueError, TypeError):
|
||||
pass
|
||||
|
||||
async def _get_wattage(self, rpc_estats: dict = None) -> Optional[int]:
|
||||
if rpc_estats is None:
|
||||
async def _get_wattage(self, rpc_stats: dict = None) -> Optional[int]:
|
||||
if rpc_stats is None:
|
||||
try:
|
||||
rpc_estats = await self.rpc.estats()
|
||||
rpc_stats = await self.rpc.stats()
|
||||
except APIError:
|
||||
pass
|
||||
|
||||
if rpc_estats is not None:
|
||||
if rpc_stats is not None:
|
||||
try:
|
||||
parsed_estats = self.parse_estats(rpc_estats)["STATS"][0]["MM ID0"]
|
||||
return int(parsed_estats["WALLPOWER"])
|
||||
unparsed_stats = rpc_stats["STATS"][0]["MM ID0"]
|
||||
parsed_stats = self.parse_stats(unparsed_stats)
|
||||
return int(parsed_stats["WALLPOWER"][0])
|
||||
except (IndexError, KeyError, ValueError, TypeError):
|
||||
pass
|
||||
|
||||
async def _get_fans(self, rpc_estats: dict = None) -> List[Fan]:
|
||||
async def _get_fans(self, rpc_stats: dict = None) -> List[Fan]:
|
||||
if self.expected_fans is None:
|
||||
return []
|
||||
|
||||
if rpc_estats is None:
|
||||
if rpc_stats is None:
|
||||
try:
|
||||
rpc_estats = await self.rpc.estats()
|
||||
rpc_stats = await self.rpc.stats()
|
||||
except APIError:
|
||||
pass
|
||||
|
||||
fans_data = [Fan() for _ in range(self.expected_fans)]
|
||||
if rpc_estats is not None:
|
||||
if rpc_stats is not None:
|
||||
try:
|
||||
parsed_estats = self.parse_estats(rpc_estats)["STATS"][0]["MM ID0"]
|
||||
unparsed_stats = rpc_stats["STATS"][0]["MM ID0"]
|
||||
parsed_stats = self.parse_stats(unparsed_stats)
|
||||
except LookupError:
|
||||
return fans_data
|
||||
|
||||
for fan in range(self.expected_fans):
|
||||
try:
|
||||
fans_data[fan].speed = int(parsed_estats[f"Fan{fan + 1}"])
|
||||
fans_data[fan].speed = int(parsed_stats[f"Fan{fan + 1}"][0])
|
||||
except (IndexError, KeyError, ValueError, TypeError):
|
||||
pass
|
||||
return fans_data
|
||||
|
||||
async def _get_fault_light(self, rpc_estats: dict = None) -> Optional[bool]:
|
||||
async def _get_fault_light(self, rpc_stats: dict = None) -> Optional[bool]:
|
||||
if self.light:
|
||||
return self.light
|
||||
if rpc_estats is None:
|
||||
if rpc_stats is None:
|
||||
try:
|
||||
rpc_estats = await self.rpc.estats()
|
||||
rpc_stats = await self.rpc.stats()
|
||||
except APIError:
|
||||
pass
|
||||
|
||||
if rpc_estats is not None:
|
||||
if rpc_stats is not None:
|
||||
try:
|
||||
parsed_estats = self.parse_estats(rpc_estats)["STATS"][0]["MM ID0"]
|
||||
led = int(parsed_estats["Led"])
|
||||
unparsed_stats = rpc_stats["STATS"][0]["MM ID0"]
|
||||
parsed_stats = self.parse_stats(unparsed_stats)
|
||||
led = int(parsed_stats["Led"][0])
|
||||
return True if led == 1 else False
|
||||
except (IndexError, KeyError, ValueError, TypeError):
|
||||
pass
|
||||
|
||||
try:
|
||||
data = await self.rpc.ascset(0, "led", "1-255")
|
||||
except APIError:
|
||||
return False
|
||||
try:
|
||||
if data["STATUS"][0]["Msg"] == "ASC 0 set info: LED[1]":
|
||||
return True
|
||||
except LookupError:
|
||||
pass
|
||||
return False
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
import logging
|
||||
from pathlib import Path
|
||||
from typing import List, Optional
|
||||
|
||||
import aiofiles
|
||||
|
||||
@@ -27,7 +28,7 @@ from pyasic.device.algorithm import AlgoHashRate
|
||||
from pyasic.errors import APIError
|
||||
from pyasic.miners.data import DataFunction, DataLocations, DataOptions, RPCAPICommand
|
||||
from pyasic.miners.device.firmware import StockFirmware
|
||||
from pyasic.rpc.btminer import BTMinerRPCAPI, BTMinerV3RPCAPI
|
||||
from pyasic.rpc.btminer import BTMinerRPCAPI
|
||||
|
||||
BTMINER_DATA_LOC = DataLocations(
|
||||
**{
|
||||
@@ -293,7 +294,7 @@ class BTMiner(StockFirmware):
|
||||
|
||||
async def _get_mac(
|
||||
self, rpc_summary: dict = None, rpc_get_miner_info: dict = None
|
||||
) -> str | None:
|
||||
) -> Optional[str]:
|
||||
if rpc_get_miner_info is None:
|
||||
try:
|
||||
rpc_get_miner_info = await self.rpc.get_miner_info()
|
||||
@@ -320,7 +321,7 @@ class BTMiner(StockFirmware):
|
||||
except LookupError:
|
||||
pass
|
||||
|
||||
async def _get_api_ver(self, rpc_get_version: dict = None) -> str | None:
|
||||
async def _get_api_ver(self, rpc_get_version: dict = None) -> Optional[str]:
|
||||
if rpc_get_version is None:
|
||||
try:
|
||||
rpc_get_version = await self.rpc.get_version()
|
||||
@@ -345,7 +346,7 @@ class BTMiner(StockFirmware):
|
||||
|
||||
async def _get_fw_ver(
|
||||
self, rpc_get_version: dict = None, rpc_summary: dict = None
|
||||
) -> str | None:
|
||||
) -> Optional[str]:
|
||||
if rpc_get_version is None:
|
||||
try:
|
||||
rpc_get_version = await self.rpc.get_version()
|
||||
@@ -378,7 +379,7 @@ class BTMiner(StockFirmware):
|
||||
|
||||
return self.fw_ver
|
||||
|
||||
async def _get_hostname(self, rpc_get_miner_info: dict = None) -> str | None:
|
||||
async def _get_hostname(self, rpc_get_miner_info: dict = None) -> Optional[str]:
|
||||
hostname = None
|
||||
if rpc_get_miner_info is None:
|
||||
try:
|
||||
@@ -394,7 +395,7 @@ class BTMiner(StockFirmware):
|
||||
|
||||
return hostname
|
||||
|
||||
async def _get_hashrate(self, rpc_summary: dict = None) -> AlgoHashRate | None:
|
||||
async def _get_hashrate(self, rpc_summary: dict = None) -> Optional[AlgoHashRate]:
|
||||
if rpc_summary is None:
|
||||
try:
|
||||
rpc_summary = await self.rpc.summary()
|
||||
@@ -409,9 +410,8 @@ class BTMiner(StockFirmware):
|
||||
).into(self.algo.unit.default)
|
||||
except LookupError:
|
||||
pass
|
||||
return None
|
||||
|
||||
async def _get_hashboards(self, rpc_devs: dict = None) -> list[HashBoard]:
|
||||
async def _get_hashboards(self, rpc_devs: dict = None) -> List[HashBoard]:
|
||||
if self.expected_hashboards is None:
|
||||
return []
|
||||
|
||||
@@ -450,7 +450,7 @@ class BTMiner(StockFirmware):
|
||||
|
||||
return hashboards
|
||||
|
||||
async def _get_env_temp(self, rpc_summary: dict = None) -> float | None:
|
||||
async def _get_env_temp(self, rpc_summary: dict = None) -> Optional[float]:
|
||||
if rpc_summary is None:
|
||||
try:
|
||||
rpc_summary = await self.rpc.summary()
|
||||
@@ -462,9 +462,8 @@ class BTMiner(StockFirmware):
|
||||
return rpc_summary["SUMMARY"][0]["Env Temp"]
|
||||
except LookupError:
|
||||
pass
|
||||
return None
|
||||
|
||||
async def _get_wattage(self, rpc_summary: dict = None) -> int | None:
|
||||
async def _get_wattage(self, rpc_summary: dict = None) -> Optional[int]:
|
||||
if rpc_summary is None:
|
||||
try:
|
||||
rpc_summary = await self.rpc.summary()
|
||||
@@ -477,9 +476,8 @@ class BTMiner(StockFirmware):
|
||||
return wattage if not wattage == -1 else None
|
||||
except LookupError:
|
||||
pass
|
||||
return None
|
||||
|
||||
async def _get_wattage_limit(self, rpc_summary: dict = None) -> int | None:
|
||||
async def _get_wattage_limit(self, rpc_summary: dict = None) -> Optional[int]:
|
||||
if rpc_summary is None:
|
||||
try:
|
||||
rpc_summary = await self.rpc.summary()
|
||||
@@ -491,11 +489,10 @@ class BTMiner(StockFirmware):
|
||||
return rpc_summary["SUMMARY"][0]["Power Limit"]
|
||||
except LookupError:
|
||||
pass
|
||||
return None
|
||||
|
||||
async def _get_fans(
|
||||
self, rpc_summary: dict = None, rpc_get_psu: dict = None
|
||||
) -> list[Fan]:
|
||||
) -> List[Fan]:
|
||||
if self.expected_fans is None:
|
||||
return []
|
||||
|
||||
@@ -520,7 +517,7 @@ class BTMiner(StockFirmware):
|
||||
|
||||
async def _get_fan_psu(
|
||||
self, rpc_summary: dict = None, rpc_get_psu: dict = None
|
||||
) -> int | None:
|
||||
) -> Optional[int]:
|
||||
if rpc_summary is None:
|
||||
try:
|
||||
rpc_summary = await self.rpc.summary()
|
||||
@@ -544,11 +541,10 @@ class BTMiner(StockFirmware):
|
||||
return int(rpc_get_psu["Msg"]["fan_speed"])
|
||||
except (KeyError, TypeError):
|
||||
pass
|
||||
return None
|
||||
|
||||
async def _get_errors(
|
||||
self, rpc_summary: dict = None, rpc_get_error_code: dict = None
|
||||
) -> list[MinerErrorData]:
|
||||
) -> List[MinerErrorData]:
|
||||
errors = []
|
||||
if rpc_get_error_code is None and rpc_summary is None:
|
||||
try:
|
||||
@@ -585,7 +581,7 @@ class BTMiner(StockFirmware):
|
||||
|
||||
async def _get_expected_hashrate(
|
||||
self, rpc_summary: dict = None
|
||||
) -> AlgoHashRate | None:
|
||||
) -> Optional[AlgoHashRate]:
|
||||
if rpc_summary is None:
|
||||
try:
|
||||
rpc_summary = await self.rpc.summary()
|
||||
@@ -602,9 +598,8 @@ class BTMiner(StockFirmware):
|
||||
|
||||
except LookupError:
|
||||
pass
|
||||
return None
|
||||
|
||||
async def _get_fault_light(self, rpc_get_miner_info: dict = None) -> bool | None:
|
||||
async def _get_fault_light(self, rpc_get_miner_info: dict = None) -> Optional[bool]:
|
||||
if rpc_get_miner_info is None:
|
||||
try:
|
||||
rpc_get_miner_info = await self.rpc.get_miner_info()
|
||||
@@ -642,7 +637,7 @@ class BTMiner(StockFirmware):
|
||||
async def set_hostname(self, hostname: str):
|
||||
await self.rpc.set_hostname(hostname)
|
||||
|
||||
async def _is_mining(self, rpc_status: dict = None) -> bool | None:
|
||||
async def _is_mining(self, rpc_status: dict = None) -> Optional[bool]:
|
||||
if rpc_status is None:
|
||||
try:
|
||||
rpc_status = await self.rpc.status()
|
||||
@@ -660,9 +655,8 @@ class BTMiner(StockFirmware):
|
||||
return True if rpc_status["Msg"]["mineroff"] == "false" else False
|
||||
except LookupError:
|
||||
pass
|
||||
return False
|
||||
|
||||
async def _get_uptime(self, rpc_summary: dict = None) -> int | None:
|
||||
async def _get_uptime(self, rpc_summary: dict = None) -> Optional[int]:
|
||||
if rpc_summary is None:
|
||||
try:
|
||||
rpc_summary = await self.rpc.summary()
|
||||
@@ -675,7 +669,7 @@ class BTMiner(StockFirmware):
|
||||
except LookupError:
|
||||
pass
|
||||
|
||||
async def _get_pools(self, rpc_pools: dict = None) -> list[PoolMetrics]:
|
||||
async def _get_pools(self, rpc_pools: dict = None) -> List[PoolMetrics]:
|
||||
if rpc_pools is None:
|
||||
try:
|
||||
rpc_pools = await self.rpc.pools()
|
||||
@@ -748,380 +742,3 @@ class BTMiner(StockFirmware):
|
||||
exc_info=True,
|
||||
)
|
||||
raise
|
||||
|
||||
|
||||
BTMINERV3_DATA_LOC = DataLocations(
|
||||
**{
|
||||
str(DataOptions.MAC): DataFunction(
|
||||
"_get_mac", [RPCAPICommand("rpc_get_device_info", "get_device_info")]
|
||||
),
|
||||
str(DataOptions.API_VERSION): DataFunction(
|
||||
"_get_api_version",
|
||||
[RPCAPICommand("rpc_get_device_info", "get_device_info")],
|
||||
),
|
||||
str(DataOptions.FW_VERSION): DataFunction(
|
||||
"_get_firmware_version",
|
||||
[RPCAPICommand("rpc_get_device_info", "get_device_info")],
|
||||
),
|
||||
str(DataOptions.HOSTNAME): DataFunction(
|
||||
"_get_hostname", [RPCAPICommand("rpc_get_device_info", "get_device_info")]
|
||||
),
|
||||
str(DataOptions.FAULT_LIGHT): DataFunction(
|
||||
"_get_light_flashing",
|
||||
[RPCAPICommand("rpc_get_device_info", "get_device_info")],
|
||||
),
|
||||
str(DataOptions.WATTAGE_LIMIT): DataFunction(
|
||||
"_get_wattage_limit",
|
||||
[RPCAPICommand("rpc_get_device_info", "get_device_info")],
|
||||
),
|
||||
str(DataOptions.FANS): DataFunction(
|
||||
"_get_fans",
|
||||
[RPCAPICommand("rpc_get_miner_status_summary", "get_miner_status_summary")],
|
||||
),
|
||||
str(DataOptions.FAN_PSU): DataFunction(
|
||||
"_get_psu_fans", [RPCAPICommand("rpc_get_device_info", "get_device_info")]
|
||||
),
|
||||
str(DataOptions.HASHBOARDS): DataFunction(
|
||||
"_get_hashboards",
|
||||
[
|
||||
RPCAPICommand("rpc_get_device_info", "get_device_info"),
|
||||
RPCAPICommand(
|
||||
"rpc_get_miner_status_edevs",
|
||||
"get_miner_status_edevs",
|
||||
),
|
||||
],
|
||||
),
|
||||
str(DataOptions.POOLS): DataFunction(
|
||||
"_get_pools",
|
||||
[RPCAPICommand("rpc_get_miner_status_summary", "get_miner_status_summary")],
|
||||
),
|
||||
str(DataOptions.UPTIME): DataFunction(
|
||||
"_get_uptime",
|
||||
[RPCAPICommand("rpc_get_miner_status_summary", "get_miner_status_summary")],
|
||||
),
|
||||
str(DataOptions.WATTAGE): DataFunction(
|
||||
"_get_wattage",
|
||||
[RPCAPICommand("rpc_get_miner_status_summary", "get_miner_status_summary")],
|
||||
),
|
||||
str(DataOptions.HASHRATE): DataFunction(
|
||||
"_get_hashrate",
|
||||
[RPCAPICommand("rpc_get_miner_status_summary", "get_miner_status_summary")],
|
||||
),
|
||||
str(DataOptions.EXPECTED_HASHRATE): DataFunction(
|
||||
"_get_expected_hashrate",
|
||||
[RPCAPICommand("rpc_get_miner_status_summary", "get_miner_status_summary")],
|
||||
),
|
||||
str(DataOptions.ENVIRONMENT_TEMP): DataFunction(
|
||||
"_get_env_temp",
|
||||
[RPCAPICommand("rpc_get_miner_status_summary", "get_miner_status_summary")],
|
||||
),
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
class BTMinerV3(StockFirmware):
|
||||
_rpc_cls = BTMinerV3RPCAPI
|
||||
rpc: BTMinerV3RPCAPI
|
||||
|
||||
data_locations = BTMINERV3_DATA_LOC
|
||||
|
||||
supports_shutdown = True
|
||||
supports_autotuning = True
|
||||
supports_power_modes = True
|
||||
|
||||
async def fault_light_off(self) -> bool:
|
||||
try:
|
||||
data = await self.rpc.set_system_led()
|
||||
except APIError:
|
||||
return False
|
||||
if data:
|
||||
if "code" in data.keys():
|
||||
if data["code"] == 0:
|
||||
self.light = False
|
||||
return True
|
||||
return False
|
||||
|
||||
async def fault_light_on(self) -> bool:
|
||||
try:
|
||||
data = await self.rpc.set_system_led(
|
||||
leds=[
|
||||
{
|
||||
{"color": "red", "period": 60, "duration": 20, "start": 0},
|
||||
}
|
||||
],
|
||||
)
|
||||
except APIError:
|
||||
return False
|
||||
if data:
|
||||
if "code" in data.keys():
|
||||
if data["code"] == 0:
|
||||
self.light = True
|
||||
return True
|
||||
return False
|
||||
|
||||
async def reboot(self) -> bool:
|
||||
try:
|
||||
data = await self.rpc.set_system_reboot()
|
||||
except APIError:
|
||||
return False
|
||||
if data.get("msg"):
|
||||
if data["msg"] == "ok":
|
||||
return True
|
||||
return False
|
||||
|
||||
async def restart_backend(self) -> bool:
|
||||
try:
|
||||
data = await self.rpc.set_miner_service("restart")
|
||||
except APIError:
|
||||
return False
|
||||
if data.get("msg"):
|
||||
if data["msg"] == "ok":
|
||||
return True
|
||||
return False
|
||||
|
||||
async def stop_mining(self) -> bool:
|
||||
try:
|
||||
data = await self.rpc.set_miner_service("stop")
|
||||
except APIError:
|
||||
return False
|
||||
if data.get("msg"):
|
||||
if data["msg"] == "ok":
|
||||
return True
|
||||
return False
|
||||
|
||||
async def resume_mining(self) -> bool:
|
||||
try:
|
||||
data = await self.rpc.set_miner_service("start")
|
||||
except APIError:
|
||||
return False
|
||||
if data.get("msg"):
|
||||
if data["msg"] == "ok":
|
||||
return True
|
||||
return False
|
||||
|
||||
async def set_power_limit(self, wattage: int) -> bool:
|
||||
try:
|
||||
await self.rpc.set_miner_power_limit(wattage)
|
||||
except Exception as e:
|
||||
logging.warning(f"{self} set_power_limit: {e}")
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
async def _get_mac(self, rpc_get_device_info: dict = None) -> str | None:
|
||||
if rpc_get_device_info is None:
|
||||
try:
|
||||
rpc_get_device_info = await self.rpc.get_device_info()
|
||||
except APIError:
|
||||
return None
|
||||
return rpc_get_device_info.get("msg", {}).get("network", {}).get("mac")
|
||||
|
||||
async def _get_api_version(self, rpc_get_device_info: dict = None) -> str | None:
|
||||
if rpc_get_device_info is None:
|
||||
try:
|
||||
rpc_get_device_info = await self.rpc.get_device_info()
|
||||
except APIError:
|
||||
return None
|
||||
return rpc_get_device_info.get("msg", {}).get("system", {}).get("api")
|
||||
|
||||
async def _get_firmware_version(
|
||||
self, rpc_get_device_info: dict = None
|
||||
) -> str | None:
|
||||
if rpc_get_device_info is None:
|
||||
try:
|
||||
rpc_get_device_info = await self.rpc.get_device_info()
|
||||
except APIError:
|
||||
return None
|
||||
return rpc_get_device_info.get("msg", {}).get("system", {}).get("fwversion")
|
||||
|
||||
async def _get_hostname(self, rpc_get_device_info: dict = None) -> str | None:
|
||||
if rpc_get_device_info is None:
|
||||
try:
|
||||
rpc_get_device_info = await self.rpc.get_device_info()
|
||||
except APIError:
|
||||
return None
|
||||
return rpc_get_device_info.get("msg", {}).get("network", {}).get("hostname")
|
||||
|
||||
async def _get_light_flashing(
|
||||
self, rpc_get_device_info: dict = None
|
||||
) -> bool | None:
|
||||
if rpc_get_device_info is None:
|
||||
try:
|
||||
rpc_get_device_info = await self.rpc.get_device_info()
|
||||
except APIError:
|
||||
return None
|
||||
val = rpc_get_device_info.get("msg", {}).get("system", {}).get("ledstatus")
|
||||
if isinstance(val, str):
|
||||
return val != "auto"
|
||||
return None
|
||||
|
||||
async def _get_wattage_limit(
|
||||
self, rpc_get_device_info: dict = None
|
||||
) -> float | None:
|
||||
if rpc_get_device_info is None:
|
||||
try:
|
||||
rpc_get_device_info = await self.rpc.get_device_info()
|
||||
except APIError:
|
||||
return None
|
||||
val = rpc_get_device_info.get("msg", {}).get("miner", {}).get("power-limit-set")
|
||||
try:
|
||||
return float(val)
|
||||
except (ValueError, TypeError):
|
||||
return None
|
||||
|
||||
async def _get_fans(self, rpc_get_miner_status_summary: dict = None) -> list[Fan]:
|
||||
if rpc_get_miner_status_summary is None:
|
||||
try:
|
||||
rpc_get_miner_status_summary = await self.rpc.get_miner_status_summary()
|
||||
except APIError:
|
||||
return []
|
||||
fans = []
|
||||
summary = rpc_get_miner_status_summary.get("msg", {}).get("summary", {})
|
||||
for idx, direction in enumerate(["in", "out"]):
|
||||
rpm = summary.get(f"fan-speed-{direction}")
|
||||
if rpm is not None:
|
||||
fans.append(Fan(speed=rpm))
|
||||
return fans
|
||||
|
||||
async def _get_psu_fans(self, rpc_get_device_info: dict = None) -> list[Fan]:
|
||||
if rpc_get_device_info is None:
|
||||
try:
|
||||
rpc_get_device_info = await self.rpc.get_device_info()
|
||||
except APIError:
|
||||
return []
|
||||
rpm = rpc_get_device_info.get("msg", {}).get("power", {}).get("fanspeed")
|
||||
return [Fan(speed=rpm)] if rpm is not None else []
|
||||
|
||||
async def _get_hashboards(
|
||||
self,
|
||||
rpc_get_device_info: dict = None,
|
||||
rpc_get_miner_status_edevs: dict = None,
|
||||
) -> list[HashBoard]:
|
||||
if rpc_get_device_info is None:
|
||||
try:
|
||||
rpc_get_device_info = await self.rpc.get_device_info()
|
||||
except APIError:
|
||||
return []
|
||||
if rpc_get_miner_status_edevs is None:
|
||||
try:
|
||||
rpc_get_miner_status_edevs = await self.rpc.get_miner_status_edevs()
|
||||
except APIError:
|
||||
return []
|
||||
|
||||
boards = []
|
||||
board_count = (
|
||||
rpc_get_device_info.get("msg", {}).get("hardware", {}).get("boards", 3)
|
||||
)
|
||||
edevs = rpc_get_miner_status_edevs.get("msg", {}).get("edevs", [])
|
||||
for idx in range(board_count):
|
||||
board_data = edevs[idx] if idx < len(edevs) else {}
|
||||
boards.append(
|
||||
HashBoard(
|
||||
slot=idx,
|
||||
hashrate=self.algo.hashrate(
|
||||
rate=board_data.get("hash-average", 0), unit=self.algo.unit.TH
|
||||
).into(self.algo.unit.default),
|
||||
temp=board_data.get("chip-temp-min"),
|
||||
inlet_temp=board_data.get("chip-temp-min"),
|
||||
outlet_temp=board_data.get("chip-temp-max"),
|
||||
serial_number=board_data.get(f"pcbsn{idx}"),
|
||||
chips=board_data.get("effective-chips"),
|
||||
expected_chips=self.expected_chips,
|
||||
active=(board_data.get("hash-average") or 0) > 0,
|
||||
missing=False,
|
||||
tuned=True,
|
||||
)
|
||||
)
|
||||
return boards
|
||||
|
||||
async def _get_pools(
|
||||
self, rpc_get_miner_status_summary: dict = None
|
||||
) -> list[PoolMetrics]:
|
||||
if rpc_get_miner_status_summary is None:
|
||||
try:
|
||||
rpc_get_miner_status_summary = await self.rpc.get_miner_status_summary()
|
||||
except APIError:
|
||||
return []
|
||||
pools = []
|
||||
msg_pools = rpc_get_miner_status_summary.get("msg", {}).get("pools", [])
|
||||
for idx, pool in enumerate(msg_pools):
|
||||
pools.append(
|
||||
PoolMetrics(
|
||||
index=idx,
|
||||
user=pool.get("account"),
|
||||
alive=pool.get("status") == "alive",
|
||||
active=pool.get("stratum-active"),
|
||||
url=pool.get("url"),
|
||||
)
|
||||
)
|
||||
return pools
|
||||
|
||||
async def _get_uptime(
|
||||
self, rpc_get_miner_status_summary: dict = None
|
||||
) -> int | None:
|
||||
if rpc_get_miner_status_summary is None:
|
||||
try:
|
||||
rpc_get_miner_status_summary = await self.rpc.get_miner_status_summary()
|
||||
except APIError:
|
||||
return None
|
||||
return (
|
||||
rpc_get_miner_status_summary.get("msg", {})
|
||||
.get("summary", {})
|
||||
.get("elapsed")
|
||||
)
|
||||
|
||||
async def _get_wattage(
|
||||
self, rpc_get_miner_status_summary: dict = None
|
||||
) -> float | None:
|
||||
if rpc_get_miner_status_summary is None:
|
||||
try:
|
||||
rpc_get_miner_status_summary = await self.rpc.get_miner_status_summary()
|
||||
except APIError:
|
||||
return None
|
||||
return (
|
||||
rpc_get_miner_status_summary.get("msg", {})
|
||||
.get("summary", {})
|
||||
.get("power-realtime")
|
||||
)
|
||||
|
||||
async def _get_hashrate(
|
||||
self, rpc_get_miner_status_summary: dict = None
|
||||
) -> float | None:
|
||||
if rpc_get_miner_status_summary is None:
|
||||
try:
|
||||
rpc_get_miner_status_summary = await self.rpc.get_miner_status_summary()
|
||||
except APIError:
|
||||
return None
|
||||
return (
|
||||
rpc_get_miner_status_summary.get("msg", {})
|
||||
.get("summary", {})
|
||||
.get("hash-realtime")
|
||||
)
|
||||
|
||||
async def _get_expected_hashrate(
|
||||
self, rpc_get_miner_status_summary: dict = None
|
||||
) -> float | None:
|
||||
if rpc_get_miner_status_summary is None:
|
||||
try:
|
||||
rpc_get_miner_status_summary = await self.rpc.get_miner_status_summary()
|
||||
except APIError:
|
||||
return None
|
||||
return (
|
||||
rpc_get_miner_status_summary.get("msg", {})
|
||||
.get("summary", {})
|
||||
.get("factory-hash")
|
||||
)
|
||||
|
||||
async def _get_env_temp(
|
||||
self, rpc_get_miner_status_summary: dict = None
|
||||
) -> float | None:
|
||||
if rpc_get_miner_status_summary is None:
|
||||
try:
|
||||
rpc_get_miner_status_summary = await self.rpc.get_miner_status_summary()
|
||||
except APIError:
|
||||
return None
|
||||
return (
|
||||
rpc_get_miner_status_summary.get("msg", {})
|
||||
.get("summary", {})
|
||||
.get("environment-temperature")
|
||||
)
|
||||
|
||||
@@ -115,18 +115,11 @@ class ESPMiner(BaseMiner):
|
||||
|
||||
if web_system_info is not None:
|
||||
try:
|
||||
small_core_count = web_system_info.get("smallCoreCount")
|
||||
asic_count = web_system_info.get("asicCount")
|
||||
frequency = web_system_info.get("frequency")
|
||||
|
||||
if asic_count is None:
|
||||
try:
|
||||
asic_info = await self.web.asic_info()
|
||||
asic_count = asic_info.get("asicCount")
|
||||
except APIError:
|
||||
pass
|
||||
|
||||
expected_hashrate = small_core_count * asic_count * frequency
|
||||
expected_hashrate = (
|
||||
web_system_info.get("smallCoreCount")
|
||||
* web_system_info.get("asicCount")
|
||||
* web_system_info.get("frequency")
|
||||
)
|
||||
|
||||
return self.algo.hashrate(
|
||||
rate=float(expected_hashrate), unit=self.algo.unit.MH
|
||||
|
||||
@@ -293,12 +293,9 @@ class VNish(VNishFirmware, BMMiner):
|
||||
try:
|
||||
web_settings = await self.web.settings()
|
||||
web_presets = await self.web.autotune_presets()
|
||||
web_perf_summary = (await self.web.perf_summary()) or {}
|
||||
except APIError:
|
||||
return self.config
|
||||
self.config = MinerConfig.from_vnish(
|
||||
web_settings, web_presets, web_perf_summary
|
||||
)
|
||||
self.config = MinerConfig.from_vnish(web_settings, web_presets)
|
||||
return self.config
|
||||
|
||||
async def set_power_limit(self, wattage: int) -> bool:
|
||||
|
||||
@@ -13,23 +13,23 @@
|
||||
# See the License for the specific language governing permissions and -
|
||||
# limitations under the License. -
|
||||
# ------------------------------------------------------------------------------
|
||||
from pyasic.miners.backends.btminer import BTMiner, BTMinerV3
|
||||
from pyasic.miners.backends.btminer import BTMiner
|
||||
|
||||
|
||||
class M7X(BTMinerV3):
|
||||
pass
|
||||
class M7X(BTMiner):
|
||||
supports_autotuning = True
|
||||
|
||||
|
||||
class M6X(BTMinerV3):
|
||||
pass
|
||||
class M6X(BTMiner):
|
||||
supports_autotuning = True
|
||||
|
||||
|
||||
class M5X(BTMinerV3):
|
||||
pass
|
||||
class M5X(BTMiner):
|
||||
supports_autotuning = True
|
||||
|
||||
|
||||
class M3X(BTMinerV3):
|
||||
pass
|
||||
class M3X(BTMiner):
|
||||
supports_autotuning = True
|
||||
|
||||
|
||||
class M2X(BTMiner):
|
||||
|
||||
@@ -126,15 +126,6 @@ class S19jPro(AntMinerMake):
|
||||
algo = MinerAlgo.SHA256
|
||||
|
||||
|
||||
class S19jPlus(AntMinerMake):
|
||||
raw_model = MinerModel.ANTMINER.S19jPlus
|
||||
|
||||
expected_chips = 108
|
||||
expected_fans = 4
|
||||
expected_hashboards = 3
|
||||
algo = MinerAlgo.SHA256
|
||||
|
||||
|
||||
class S19jProNoPIC(AntMinerMake):
|
||||
raw_model = MinerModel.ANTMINER.S19jProNoPIC
|
||||
|
||||
@@ -225,15 +216,6 @@ class S19KPro(AntMinerMake):
|
||||
algo = MinerAlgo.SHA256
|
||||
|
||||
|
||||
class S19ProA(AntMinerMake):
|
||||
raw_model = MinerModel.ANTMINER.S19ProA
|
||||
|
||||
expected_chips = 114
|
||||
expected_fans = 4
|
||||
expected_hashboards = 3
|
||||
algo = MinerAlgo.SHA256
|
||||
|
||||
|
||||
class S19jXP(AntMinerMake):
|
||||
raw_model = MinerModel.ANTMINER.S19jXP
|
||||
|
||||
@@ -241,12 +223,3 @@ class S19jXP(AntMinerMake):
|
||||
expected_fans = 4
|
||||
expected_hashboards = 3
|
||||
algo = MinerAlgo.SHA256
|
||||
|
||||
|
||||
class S19XPHydro(AntMinerMake):
|
||||
raw_model = MinerModel.ANTMINER.S19XPHydro
|
||||
|
||||
expected_chips = 204
|
||||
expected_fans = 0
|
||||
expected_hashboards = 3
|
||||
algo = MinerAlgo.SHA256
|
||||
|
||||
@@ -24,7 +24,6 @@ from .S19 import (
|
||||
S19i,
|
||||
S19j,
|
||||
S19jNoPIC,
|
||||
S19jPlus,
|
||||
S19jPro,
|
||||
S19jProNoPIC,
|
||||
S19jProPlus,
|
||||
@@ -36,10 +35,8 @@ from .S19 import (
|
||||
S19NoPIC,
|
||||
S19Plus,
|
||||
S19Pro,
|
||||
S19ProA,
|
||||
S19ProHydro,
|
||||
S19ProPlus,
|
||||
S19ProPlusHydro,
|
||||
S19XPHydro,
|
||||
)
|
||||
from .T19 import T19
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
# ------------------------------------------------------------------------------
|
||||
# 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.device.algorithm import MinerAlgo
|
||||
from pyasic.device.models import MinerModel
|
||||
from pyasic.miners.device.makes import AvalonMinerMake
|
||||
|
||||
|
||||
class AvalonQHome(AvalonMinerMake):
|
||||
raw_model = MinerModel.AVALONMINER.AvalonQHome
|
||||
|
||||
expected_chips = 160
|
||||
expected_fans = 2
|
||||
expected_hashboards = 1
|
||||
algo = MinerAlgo.SHA256
|
||||
@@ -1,17 +0,0 @@
|
||||
# ------------------------------------------------------------------------------
|
||||
# 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 .Q import AvalonQHome
|
||||
@@ -22,4 +22,3 @@ from .A11X import *
|
||||
from .A12X import *
|
||||
from .A15X import *
|
||||
from .nano import *
|
||||
from .Q import *
|
||||
|
||||
@@ -6,7 +6,6 @@ from pyasic.miners.device.makes import BraiinsMake
|
||||
class BMM100(BraiinsMake):
|
||||
raw_model = MinerModel.BRAIINS.BMM100
|
||||
|
||||
expected_chips = 1
|
||||
expected_hashboards = 1
|
||||
expected_fans = 1
|
||||
algo = MinerAlgo.SHA256
|
||||
@@ -15,7 +14,6 @@ class BMM100(BraiinsMake):
|
||||
class BMM101(BraiinsMake):
|
||||
raw_model = MinerModel.BRAIINS.BMM101
|
||||
|
||||
expected_chips = 1
|
||||
expected_hashboards = 1
|
||||
expected_fans = 1
|
||||
algo = MinerAlgo.SHA256
|
||||
|
||||
@@ -18,15 +18,6 @@ from pyasic.device.models import MinerModel
|
||||
from pyasic.miners.device.makes import ElphapexMake
|
||||
|
||||
|
||||
class DG1(ElphapexMake):
|
||||
raw_model = MinerModel.ELPHAPEX.DG1
|
||||
|
||||
expected_chips = 144
|
||||
expected_hashboards = 4
|
||||
expected_fans = 4
|
||||
algo = MinerAlgo.SCRYPT
|
||||
|
||||
|
||||
class DG1Plus(ElphapexMake):
|
||||
raw_model = MinerModel.ELPHAPEX.DG1Plus
|
||||
|
||||
@@ -34,12 +25,3 @@ class DG1Plus(ElphapexMake):
|
||||
expected_hashboards = 4
|
||||
expected_fans = 4
|
||||
algo = MinerAlgo.SCRYPT
|
||||
|
||||
|
||||
class DG1Home(ElphapexMake):
|
||||
raw_model = MinerModel.ELPHAPEX.DG1Home
|
||||
|
||||
expected_chips = 120
|
||||
expected_hashboards = 4
|
||||
expected_fans = 4
|
||||
algo = MinerAlgo.SCRYPT
|
||||
|
||||
@@ -1 +1 @@
|
||||
from .DG1 import DG1, DG1Home, DG1Plus
|
||||
from .DG1 import DG1Plus
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
# ------------------------------------------------------------------------------
|
||||
# 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.device.algorithm.base import GenericAlgo
|
||||
from pyasic.device.models import MinerModel
|
||||
from pyasic.miners.device.makes import GoldshellMake
|
||||
|
||||
|
||||
class Byte(GoldshellMake):
|
||||
raw_model = MinerModel.GOLDSHELL.Byte
|
||||
|
||||
expected_chips = 0
|
||||
expected_fans = 0
|
||||
expected_hashboards = 0
|
||||
algo = GenericAlgo
|
||||
@@ -1,16 +0,0 @@
|
||||
# ------------------------------------------------------------------------------
|
||||
# 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 .Byte import Byte
|
||||
@@ -13,7 +13,6 @@
|
||||
# See the License for the specific language governing permissions and -
|
||||
# limitations under the License. -
|
||||
# ------------------------------------------------------------------------------
|
||||
from .Byte import *
|
||||
from .X5 import *
|
||||
from .XBox import *
|
||||
from .XMax import *
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
# ------------------------------------------------------------------------------
|
||||
# Copyright 2024 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.device.algorithm import MinerAlgo
|
||||
from pyasic.device.models import MinerModel
|
||||
from pyasic.miners.device.makes import IceRiverMake
|
||||
|
||||
|
||||
class AL3(IceRiverMake):
|
||||
raw_model = MinerModel.ICERIVER.AL3
|
||||
|
||||
expected_chips = 156
|
||||
expected_fans = 4
|
||||
expected_hashboards = 3
|
||||
algo = MinerAlgo.BLOCKFLOW
|
||||
@@ -1 +0,0 @@
|
||||
from .AL3 import AL3
|
||||
@@ -1,2 +1 @@
|
||||
from .ALX import *
|
||||
from .KSX import *
|
||||
|
||||
@@ -1,14 +1,6 @@
|
||||
from pyasic.miners.backends.elphapex import ElphapexMiner
|
||||
from pyasic.miners.device.models import DG1, DG1Home, DG1Plus
|
||||
from pyasic.miners.device.models import DG1Plus
|
||||
|
||||
|
||||
class ElphapexDG1Plus(ElphapexMiner, DG1Plus):
|
||||
pass
|
||||
|
||||
|
||||
class ElphapexDG1(ElphapexMiner, DG1):
|
||||
pass
|
||||
|
||||
|
||||
class ElphapexDG1Home(ElphapexMiner, DG1Home):
|
||||
pass
|
||||
|
||||
@@ -1 +1 @@
|
||||
from .DG1 import ElphapexDG1, ElphapexDG1Home, ElphapexDG1Plus
|
||||
from .DG1 import ElphapexDG1Plus
|
||||
|
||||
@@ -41,7 +41,6 @@ from pyasic.miners.elphapex import *
|
||||
from pyasic.miners.goldshell import *
|
||||
from pyasic.miners.hammer import *
|
||||
from pyasic.miners.iceriver import *
|
||||
from pyasic.miners.iceriver.iceminer.ALX import IceRiverAL3
|
||||
from pyasic.miners.innosilicon import *
|
||||
from pyasic.miners.luckyminer import *
|
||||
from pyasic.miners.volcminer import *
|
||||
@@ -109,8 +108,6 @@ MINER_CLASSES = {
|
||||
"ANTMINER S19J88NOPIC": BMMinerS19jNoPIC,
|
||||
"ANTMINER S19PRO+": BMMinerS19ProPlus,
|
||||
"ANTMINER S19J PRO": BMMinerS19jPro,
|
||||
"ANTMINER S19J+": BMMinerS19jPlus,
|
||||
"ANTMINER S19J PRO+": BMMinerS19jProPlus,
|
||||
"ANTMINER S19 XP": BMMinerS19XP,
|
||||
"ANTMINER S19A": BMMinerS19a,
|
||||
"ANTMINER S19A PRO": BMMinerS19aPro,
|
||||
@@ -125,7 +122,6 @@ MINER_CLASSES = {
|
||||
"ANTMINER BHB68606": BMMinerS21, # ???
|
||||
"ANTMINER S21+": BMMinerS21Plus,
|
||||
"ANTMINER S21+ HYD.": BMMinerS21PlusHydro,
|
||||
"ANTMINER S21+ HYD": BMMinerS21PlusHydro,
|
||||
"ANTMINER S21 PRO": BMMinerS21Pro,
|
||||
"ANTMINER T21": BMMinerT21,
|
||||
"ANTMINER S21 HYD.": BMMinerS21Hydro,
|
||||
@@ -513,7 +509,6 @@ MINER_CLASSES = {
|
||||
"AVALONMINER NANO3": CGMinerAvalonNano3,
|
||||
"AVALON NANO3S": CGMinerAvalonNano3s,
|
||||
"AVALONMINER 15-194": CGMinerAvalon1566,
|
||||
"AVALON Q": CGMinerAvalonQHome,
|
||||
},
|
||||
MinerTypes.INNOSILICON: {
|
||||
None: type("InnosiliconUnknown", (Innosilicon, InnosiliconMake), {}),
|
||||
@@ -530,7 +525,6 @@ MINER_CLASSES = {
|
||||
"GOLDSHELL KDMAX": GoldshellKDMax,
|
||||
"GOLDSHELL KDBOXII": GoldshellKDBoxII,
|
||||
"GOLDSHELL KDBOXPRO": GoldshellKDBoxPro,
|
||||
"GOLDSHELL BYTE": GoldshellByte,
|
||||
},
|
||||
MinerTypes.BRAIINS_OS: {
|
||||
None: BOSMiner,
|
||||
@@ -561,20 +555,15 @@ MINER_CLASSES = {
|
||||
"ANTMINER T19": BOSMinerT19,
|
||||
"ANTMINER S21": BOSMinerS21,
|
||||
"ANTMINER S21 PRO": BOSMinerS21Pro,
|
||||
"ANTMINER S21+": BOSMinerS21Plus,
|
||||
"ANTMINER S21+ HYD.": BOSMinerS21PlusHydro,
|
||||
"ANTMINER S21 HYD.": BOSMinerS21Hydro,
|
||||
"ANTMINER T21": BOSMinerT21,
|
||||
"BRAIINS MINI MINER BMM 100": BraiinsBMM100,
|
||||
"BRAIINS MINI MINER BMM 101": BraiinsBMM101,
|
||||
"ANTMINER S19 XP HYD.": BOSMinerS19XPHydro,
|
||||
},
|
||||
MinerTypes.VNISH: {
|
||||
None: VNish,
|
||||
"L3+": VNishL3Plus,
|
||||
"ANTMINER L3+": VNishL3Plus,
|
||||
"ANTMINER L7": VNishL7,
|
||||
"ANTMINER L9": VNishL9,
|
||||
"L3+": VnishL3Plus,
|
||||
"ANTMINER L3+": VnishL3Plus,
|
||||
"ANTMINER L7": VnishL7,
|
||||
"ANTMINER S17+": VNishS17Plus,
|
||||
"ANTMINER S17 PRO": VNishS17Pro,
|
||||
"ANTMINER S19": VNishS19,
|
||||
@@ -582,24 +571,16 @@ MINER_CLASSES = {
|
||||
"ANTMINER S19 PRO": VNishS19Pro,
|
||||
"ANTMINER S19J": VNishS19j,
|
||||
"ANTMINER S19I": VNishS19i,
|
||||
"ANTMINER S19 XP": VNishS19XP,
|
||||
"ANTMINER S19 XP HYD.": VNishS19XPHydro,
|
||||
"ANTMINER S19J PRO": VNishS19jPro,
|
||||
"ANTMINER S19J PRO A": VNishS19jPro,
|
||||
"ANTMINER S19J PRO BB": VNishS19jPro,
|
||||
"ANTMINER S19A": VNishS19a,
|
||||
"ANTMINER S19 HYD.": VNishS19Hydro,
|
||||
"ANTMINER S19A PRO": VNishS19aPro,
|
||||
"ANTMINER S19 PRO A": VNishS19ProA,
|
||||
"ANTMINER S19 PRO HYD.": VNishS19ProHydro,
|
||||
"ANTMINER S19K PRO": VNishS19kPro,
|
||||
"ANTMINER T19": VNishT19,
|
||||
"ANTMINER T21": VNishT21,
|
||||
"ANTMINER S21": VNishS21,
|
||||
"ANTMINER S21+": VNishS21Plus,
|
||||
"ANTMINER S21+ HYD.": VNishS21PlusHydro,
|
||||
"ANTMINER S21 PRO": VNishS21Pro,
|
||||
"ANTMINER S21 HYD.": VNishS21Hydro,
|
||||
},
|
||||
MinerTypes.EPIC: {
|
||||
None: ePIC,
|
||||
@@ -689,7 +670,6 @@ MINER_CLASSES = {
|
||||
"KS5": IceRiverKS5,
|
||||
"KS5L": IceRiverKS5L,
|
||||
"KS5M": IceRiverKS5M,
|
||||
"10306": IceRiverAL3,
|
||||
},
|
||||
MinerTypes.HAMMER: {
|
||||
None: type("HammerUnknown", (BlackMiner, HammerMake), {}),
|
||||
@@ -702,8 +682,6 @@ MINER_CLASSES = {
|
||||
MinerTypes.ELPHAPEX: {
|
||||
None: type("ElphapexUnknown", (ElphapexMiner, ElphapexMake), {}),
|
||||
"DG1+": ElphapexDG1Plus,
|
||||
"DG1": ElphapexDG1,
|
||||
"DG1-Home": ElphapexDG1Home,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1067,45 +1045,6 @@ class MinerFactory:
|
||||
|
||||
return data
|
||||
|
||||
async def send_btminer_v3_api_command(self, ip, command):
|
||||
try:
|
||||
reader, writer = await asyncio.open_connection(ip, 4433)
|
||||
except (ConnectionError, OSError):
|
||||
return
|
||||
cmd = {"cmd": command}
|
||||
|
||||
try:
|
||||
# send the command
|
||||
json_cmd = json.dumps(cmd).encode("utf-8")
|
||||
length = len(json_cmd)
|
||||
writer.write(length.to_bytes(4, byteorder="little"))
|
||||
writer.write(json_cmd)
|
||||
await writer.drain()
|
||||
|
||||
# receive all the data
|
||||
resp_len = await reader.readexactly(4)
|
||||
data = await reader.readexactly(
|
||||
int.from_bytes(resp_len, byteorder="little")
|
||||
)
|
||||
|
||||
writer.close()
|
||||
await writer.wait_closed()
|
||||
except asyncio.CancelledError:
|
||||
writer.close()
|
||||
await writer.wait_closed()
|
||||
return
|
||||
except (ConnectionError, OSError):
|
||||
return
|
||||
if data == b"Socket connect failed: Connection refused\n":
|
||||
return
|
||||
|
||||
try:
|
||||
data = json.loads(data)
|
||||
except json.JSONDecodeError:
|
||||
return {}
|
||||
|
||||
return data
|
||||
|
||||
@staticmethod
|
||||
async def _fix_api_data(data: bytes) -> str:
|
||||
if data.endswith(b"\x00"):
|
||||
@@ -1225,18 +1164,10 @@ class MinerFactory:
|
||||
try:
|
||||
miner_model = sock_json_data["DEVDETAILS"][0]["Model"].replace("_", "")
|
||||
miner_model = miner_model[:-1] + "0"
|
||||
|
||||
return miner_model
|
||||
except (TypeError, LookupError):
|
||||
sock_json_data_v3 = await self.send_btminer_v3_api_command(
|
||||
ip, "get.device.info"
|
||||
)
|
||||
try:
|
||||
miner_model = sock_json_data_v3["msg"]["miner"]["type"].replace("_", "")
|
||||
miner_model = miner_model[:-1] + "0"
|
||||
|
||||
return miner_model
|
||||
except (TypeError, LookupError):
|
||||
pass
|
||||
pass
|
||||
|
||||
async def get_miner_model_avalonminer(self, ip: str) -> str | None:
|
||||
sock_json_data = await self.send_api_command(ip, "version")
|
||||
|
||||
@@ -1,319 +0,0 @@
|
||||
# ------------------------------------------------------------------------------
|
||||
# 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 typing import List, Optional, Union
|
||||
|
||||
from pyasic.config import MinerConfig
|
||||
from pyasic.data import Fan, MinerData
|
||||
from pyasic.data.boards import HashBoard
|
||||
from pyasic.data.pools import PoolMetrics, PoolUrl
|
||||
from pyasic.device.algorithm import AlgoHashRate, MinerAlgo
|
||||
from pyasic.errors import APIError
|
||||
from pyasic.miners.backends import GoldshellMiner
|
||||
from pyasic.miners.data import (
|
||||
DataFunction,
|
||||
DataLocations,
|
||||
DataOptions,
|
||||
RPCAPICommand,
|
||||
WebAPICommand,
|
||||
)
|
||||
from pyasic.miners.device.models import Byte
|
||||
|
||||
ALGORITHM_SCRYPT_NAME = "scrypt(LTC)"
|
||||
ALGORITHM_ZKSNARK_NAME = "zkSNARK(ALEO)"
|
||||
EXPECTED_CHIPS_PER_SCRYPT_BOARD = 5
|
||||
EXPECTED_CHIPS_PER_ZKSNARK_BOARD = 3
|
||||
|
||||
GOLDSHELL_BYTE_DATA_LOC = DataLocations(
|
||||
**{
|
||||
str(DataOptions.MAC): DataFunction(
|
||||
"_get_mac",
|
||||
[WebAPICommand("web_setting", "setting")],
|
||||
),
|
||||
str(DataOptions.API_VERSION): DataFunction(
|
||||
"_get_api_ver",
|
||||
[WebAPICommand("web_setting", "version")],
|
||||
),
|
||||
str(DataOptions.FW_VERSION): DataFunction(
|
||||
"_get_fw_ver",
|
||||
[WebAPICommand("web_status", "status")],
|
||||
),
|
||||
str(DataOptions.HASHRATE): DataFunction(
|
||||
"_get_hashrate",
|
||||
[RPCAPICommand("rpc_devs", "devs")],
|
||||
),
|
||||
str(DataOptions.EXPECTED_HASHRATE): DataFunction(
|
||||
"_get_expected_hashrate",
|
||||
[RPCAPICommand("rpc_devs", "devs")],
|
||||
),
|
||||
str(DataOptions.HASHBOARDS): DataFunction(
|
||||
"_get_hashboards",
|
||||
[
|
||||
RPCAPICommand("rpc_devs", "devs"),
|
||||
RPCAPICommand("rpc_devdetails", "devdetails"),
|
||||
],
|
||||
),
|
||||
str(DataOptions.FANS): DataFunction(
|
||||
"_get_fans",
|
||||
[RPCAPICommand("rpc_devs", "devs")],
|
||||
),
|
||||
str(DataOptions.POOLS): DataFunction(
|
||||
"_get_pools",
|
||||
[RPCAPICommand("rpc_pools", "pools")],
|
||||
),
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
class GoldshellByte(GoldshellMiner, Byte):
|
||||
|
||||
data_locations = GOLDSHELL_BYTE_DATA_LOC
|
||||
|
||||
cgdev: dict | None = None
|
||||
|
||||
async def get_data(
|
||||
self,
|
||||
allow_warning: bool = False,
|
||||
include: List[Union[str, DataOptions]] = None,
|
||||
exclude: List[Union[str, DataOptions]] = None,
|
||||
) -> MinerData:
|
||||
if self.cgdev is None:
|
||||
try:
|
||||
self.cgdev = await self.web.send_command("cgminer?cgminercmd=devs")
|
||||
except APIError:
|
||||
pass
|
||||
|
||||
scrypt_board_count = 0
|
||||
zksnark_board_count = 0
|
||||
total_wattage = 0
|
||||
total_uptime_mins = 0
|
||||
|
||||
for minfo in self.cgdev.get("minfos", []):
|
||||
|
||||
algo_name = minfo.get("name")
|
||||
|
||||
for info in minfo.get("infos", []):
|
||||
|
||||
self.expected_hashboards += 1
|
||||
self.expected_fans += 1
|
||||
|
||||
total_wattage = int(float(info.get("power", 0)))
|
||||
total_uptime_mins = int(info.get("time", 0))
|
||||
|
||||
if algo_name == ALGORITHM_SCRYPT_NAME:
|
||||
scrypt_board_count += 1
|
||||
elif algo_name == ALGORITHM_ZKSNARK_NAME:
|
||||
zksnark_board_count += 1
|
||||
|
||||
self.expected_chips = (EXPECTED_CHIPS_PER_SCRYPT_BOARD * scrypt_board_count) + (
|
||||
EXPECTED_CHIPS_PER_ZKSNARK_BOARD * zksnark_board_count
|
||||
)
|
||||
|
||||
if scrypt_board_count > 0 and zksnark_board_count == 0:
|
||||
self.algo = MinerAlgo.SCRYPT
|
||||
elif zksnark_board_count > 0 and scrypt_board_count == 0:
|
||||
self.algo = MinerAlgo.ZKSNARK
|
||||
|
||||
data = await super().get_data(allow_warning, include, exclude)
|
||||
data.expected_chips = self.expected_chips
|
||||
data.wattage = total_wattage
|
||||
data.uptime = total_uptime_mins
|
||||
data.voltage = 0
|
||||
|
||||
for board in data.hashboards:
|
||||
data.voltage += board.voltage
|
||||
|
||||
return data
|
||||
|
||||
async def get_config(self) -> MinerConfig:
|
||||
try:
|
||||
pools = await self.web.pools()
|
||||
except APIError:
|
||||
return self.config
|
||||
|
||||
self.config = MinerConfig.from_goldshell_byte(pools)
|
||||
return self.config
|
||||
|
||||
async def _get_api_ver(self, web_setting: dict = None) -> Optional[str]:
|
||||
if web_setting is None:
|
||||
try:
|
||||
web_setting = await self.web.setting()
|
||||
except APIError:
|
||||
pass
|
||||
|
||||
if web_setting is not None:
|
||||
try:
|
||||
version = web_setting.get("version")
|
||||
if version is not None:
|
||||
self.api_ver = version.strip("v")
|
||||
return self.api_ver
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
return self.api_ver
|
||||
|
||||
async def _get_expected_hashrate(
|
||||
self, rpc_devs: dict = None
|
||||
) -> Optional[AlgoHashRate]:
|
||||
if rpc_devs is None:
|
||||
try:
|
||||
rpc_devs = await self.rpc.devs()
|
||||
except APIError:
|
||||
pass
|
||||
|
||||
total_hash_rate_mh = 0
|
||||
|
||||
if rpc_devs is not None:
|
||||
for board in rpc_devs.get("DEVS", []):
|
||||
|
||||
algo_name = board.get("pool")
|
||||
|
||||
if algo_name == ALGORITHM_SCRYPT_NAME:
|
||||
total_hash_rate_mh += (
|
||||
self.algo.hashrate(
|
||||
rate=float(board.get("estimate_hash_rate", 0)),
|
||||
unit=self.algo.unit.H,
|
||||
)
|
||||
.into(self.algo.unit.MH)
|
||||
.rate
|
||||
)
|
||||
elif algo_name == ALGORITHM_ZKSNARK_NAME:
|
||||
total_hash_rate_mh += float(board.get("theory_hash", 0))
|
||||
|
||||
hash_rate = self.algo.hashrate(
|
||||
rate=total_hash_rate_mh, unit=self.algo.unit.MH
|
||||
).into(self.algo.unit.default)
|
||||
|
||||
return hash_rate
|
||||
|
||||
async def _get_hashrate(self, rpc_devs: dict = None) -> Optional[AlgoHashRate]:
|
||||
if rpc_devs is None:
|
||||
try:
|
||||
rpc_devs = await self.rpc.devs()
|
||||
except APIError:
|
||||
pass
|
||||
|
||||
total_hash_rate_mh = 0
|
||||
|
||||
if rpc_devs is not None:
|
||||
for board in rpc_devs.get("DEVS", []):
|
||||
total_hash_rate_mh += float(board.get("MHS 20s", 0))
|
||||
|
||||
hash_rate = self.algo.hashrate(
|
||||
rate=total_hash_rate_mh, unit=self.algo.unit.MH
|
||||
).into(self.algo.unit.default)
|
||||
|
||||
return hash_rate
|
||||
|
||||
async def _get_pools(self, rpc_pools: dict = None) -> List[PoolMetrics]:
|
||||
if rpc_pools is None:
|
||||
try:
|
||||
rpc_pools = await self.rpc.pools()
|
||||
except APIError:
|
||||
pass
|
||||
|
||||
pools_data = []
|
||||
if rpc_pools is not None:
|
||||
try:
|
||||
pools = rpc_pools.get("POOLS", [])
|
||||
for index, pool_info in enumerate(pools):
|
||||
url = pool_info.get("URL")
|
||||
pool_url = PoolUrl.from_str(url) if url else None
|
||||
pool_data = PoolMetrics(
|
||||
accepted=pool_info.get("Accepted"),
|
||||
rejected=pool_info.get("Rejected"),
|
||||
active=pool_info.get("Stratum Active"),
|
||||
alive=pool_info.get("Status") == "Alive",
|
||||
url=pool_url,
|
||||
user=pool_info.get("User"),
|
||||
index=index,
|
||||
)
|
||||
pools_data.append(pool_data)
|
||||
except LookupError:
|
||||
pass
|
||||
return pools_data
|
||||
|
||||
async def _get_hashboards(
|
||||
self, rpc_devs: dict = None, rpc_devdetails: dict = None
|
||||
) -> List[HashBoard]:
|
||||
if rpc_devs is None:
|
||||
try:
|
||||
rpc_devs = await self.rpc.devs()
|
||||
except APIError:
|
||||
pass
|
||||
|
||||
hashboards = [
|
||||
HashBoard(slot=i, expected_chips=self.expected_chips)
|
||||
for i in range(self.expected_hashboards)
|
||||
]
|
||||
|
||||
if rpc_devs is not None:
|
||||
for board in rpc_devs.get("DEVS", []):
|
||||
b_id = board["PGA"]
|
||||
hashboards[b_id].hashrate = self.algo.hashrate(
|
||||
rate=float(board["MHS 20s"]), unit=self.algo.unit.MH
|
||||
).into(self.algo.unit.default)
|
||||
hashboards[b_id].chip_temp = board["tstemp-1"]
|
||||
hashboards[b_id].temp = board["tstemp-2"]
|
||||
hashboards[b_id].voltage = board["voltage"]
|
||||
hashboards[b_id].active = board["Status"] == "Alive"
|
||||
hashboards[b_id].missing = False
|
||||
|
||||
algo_name = board.get("pool")
|
||||
|
||||
if algo_name == ALGORITHM_SCRYPT_NAME:
|
||||
hashboards[b_id].expected_chips = EXPECTED_CHIPS_PER_SCRYPT_BOARD
|
||||
elif algo_name == ALGORITHM_ZKSNARK_NAME:
|
||||
hashboards[b_id].expected_chips = EXPECTED_CHIPS_PER_ZKSNARK_BOARD
|
||||
|
||||
if rpc_devdetails is None:
|
||||
try:
|
||||
rpc_devdetails = await self.rpc.devdetails()
|
||||
except APIError:
|
||||
pass
|
||||
|
||||
if rpc_devdetails is not None:
|
||||
for board in rpc_devdetails.get("DEVS", []):
|
||||
b_id = board["DEVDETAILS"]
|
||||
hashboards[b_id].chips = board["chips-nr"]
|
||||
|
||||
return hashboards
|
||||
|
||||
async def _get_fans(self, rpc_devs: dict = None) -> List[Fan]:
|
||||
if self.expected_fans is None:
|
||||
return []
|
||||
|
||||
if rpc_devs is None:
|
||||
try:
|
||||
rpc_devs = await self.rpc.devs()
|
||||
except APIError:
|
||||
pass
|
||||
|
||||
fans_data = []
|
||||
|
||||
if rpc_devs is not None:
|
||||
for board in rpc_devs.get("DEVS", []):
|
||||
if board.get("PGA") is not None:
|
||||
try:
|
||||
b_id = board["PGA"]
|
||||
fan_speed = board[f"fan{b_id}"]
|
||||
fans_data.append(fan_speed)
|
||||
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
fans = [Fan(speed=d) if d else Fan() for d in fans_data]
|
||||
|
||||
return fans
|
||||
@@ -1,16 +0,0 @@
|
||||
# ------------------------------------------------------------------------------
|
||||
# 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 .Byte import GoldshellByte
|
||||
@@ -13,7 +13,6 @@
|
||||
# See the License for the specific language governing permissions and -
|
||||
# limitations under the License. -
|
||||
# ------------------------------------------------------------------------------
|
||||
from .Byte import *
|
||||
from .X5 import *
|
||||
from .XBox import *
|
||||
from .XMax import *
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
from pyasic.miners.backends.iceriver import IceRiver
|
||||
from pyasic.miners.device.models.iceriver import AL3
|
||||
|
||||
|
||||
class IceRiverAL3(IceRiver, AL3):
|
||||
pass
|
||||
@@ -1 +0,0 @@
|
||||
from .AL3 import IceRiverAL3
|
||||
@@ -1,27 +0,0 @@
|
||||
# ------------------------------------------------------------------------------
|
||||
# Copyright 2025 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.rpc.cgminer import CGMinerRPCAPI
|
||||
|
||||
|
||||
class AvalonMinerRPCAPI(CGMinerRPCAPI):
|
||||
"""An abstraction of the AvalonMiner API.
|
||||
|
||||
Each method corresponds to an API command in AvalonMiner.
|
||||
"""
|
||||
|
||||
async def litestats(self):
|
||||
return await self.send_command("litestats")
|
||||
@@ -23,8 +23,7 @@ import json
|
||||
import logging
|
||||
import re
|
||||
import struct
|
||||
from asyncio import Future, StreamReader, StreamWriter
|
||||
from typing import Any, AsyncGenerator, Callable, Literal, Union
|
||||
from typing import Literal, Union
|
||||
|
||||
import httpx
|
||||
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
|
||||
@@ -1101,277 +1100,3 @@ class BTMinerRPCAPI(BaseMinerRPCAPI):
|
||||
</details>
|
||||
"""
|
||||
return await self.send_command("get_error_code", allow_warning=False)
|
||||
|
||||
|
||||
class BTMinerV3RPCAPI(BaseMinerRPCAPI):
|
||||
def __init__(self, ip: str, port: int = 4433, api_ver: str = "0.0.0"):
|
||||
super().__init__(ip, port, api_ver=api_ver)
|
||||
|
||||
self.reader: StreamReader | None = None
|
||||
self.writer: StreamWriter | None = None
|
||||
self.reader_loop = None
|
||||
|
||||
self.salt = None
|
||||
|
||||
self.cmd_results = {}
|
||||
self.cmd_callbacks = {"get.miner.report": set()}
|
||||
|
||||
async def connect(self):
|
||||
self.reader, self.writer = await asyncio.open_connection(
|
||||
str(self.ip), self.port
|
||||
)
|
||||
self.reader_loop = asyncio.create_task(self._read_loop())
|
||||
|
||||
async def disconnect(self):
|
||||
self.writer.close()
|
||||
await self.writer.wait_closed()
|
||||
self.reader_loop.cancel()
|
||||
|
||||
async def send_command(
|
||||
self, command: str, parameters: Any = None, **kwargs
|
||||
) -> dict:
|
||||
if self.writer is None:
|
||||
await self.connect()
|
||||
|
||||
while command in self.cmd_results:
|
||||
wait_fut = self.cmd_results[command]
|
||||
await wait_fut
|
||||
|
||||
result_fut = Future()
|
||||
self.cmd_results[command] = result_fut
|
||||
|
||||
cmd = {"cmd": command}
|
||||
if parameters is not None:
|
||||
cmd["param"] = parameters
|
||||
|
||||
if command.startswith("set."):
|
||||
salt = await self.get_salt()
|
||||
ts = int(datetime.datetime.now().timestamp())
|
||||
cmd["ts"] = ts
|
||||
token_str = cmd["cmd"] + self.pwd + salt + str(ts)
|
||||
token_hashed = bytearray(
|
||||
base64.b64encode(hashlib.sha256(token_str.encode("utf-8")).digest())
|
||||
)
|
||||
token_hashed[8] = 0
|
||||
cmd["account"] = "super"
|
||||
cmd["token"] = token_hashed.decode("ascii")
|
||||
|
||||
# send the command
|
||||
ser = json.dumps(cmd).encode("utf-8")
|
||||
header = struct.pack("<I", len(ser))
|
||||
await self._send_bytes(header + json.dumps(cmd).encode("utf-8"))
|
||||
|
||||
await result_fut
|
||||
return result_fut.result()
|
||||
|
||||
async def _read_loop(self):
|
||||
while True:
|
||||
result = await self._read_bytes()
|
||||
data = self._load_api_data(result)
|
||||
command = data["desc"]
|
||||
if command in self.cmd_callbacks:
|
||||
callbacks: list[Callable] = self.cmd_callbacks[command]
|
||||
await asyncio.gather(*[callback(data) for callback in callbacks])
|
||||
elif command in self.cmd_results:
|
||||
future: Future = self.cmd_results.pop(command)
|
||||
future.set_result(data)
|
||||
else:
|
||||
logging.error(f"Received unexpected data for {self}: {data}")
|
||||
|
||||
async def _read_bytes(self, **kwargs) -> bytes:
|
||||
header = await self.reader.readexactly(4)
|
||||
length = struct.unpack("<I", header)[0]
|
||||
return await self.reader.readexactly(length)
|
||||
|
||||
async def _send_bytes(self, data: bytes, **kwargs):
|
||||
self.writer.write(data)
|
||||
await self.writer.drain()
|
||||
|
||||
async def get_salt(self) -> str:
|
||||
if self.salt is not None:
|
||||
return self.salt
|
||||
data = await self.send_command("get.device.info", "salt")
|
||||
self.salt = data["msg"]["salt"]
|
||||
return self.salt
|
||||
|
||||
async def get_miner_report(self) -> AsyncGenerator[dict, None]:
|
||||
if self.writer is None:
|
||||
await self.connect()
|
||||
|
||||
result = asyncio.Queue()
|
||||
|
||||
async def callback(data: dict):
|
||||
await result.put(data)
|
||||
|
||||
cb_fn = callback
|
||||
|
||||
try:
|
||||
self.cmd_callbacks["get.miner.report"].add(cb_fn)
|
||||
while True:
|
||||
yield await result.get()
|
||||
if self.writer.is_closing():
|
||||
break
|
||||
finally:
|
||||
self.cmd_callbacks["get.miner.report"].remove(cb_fn)
|
||||
|
||||
async def get_system_setting(self) -> dict | None:
|
||||
return await self.send_command("get.system.setting")
|
||||
|
||||
async def get_miner_status_summary(self) -> dict | None:
|
||||
return await self.send_command("get.miner.status", parameters="summary")
|
||||
|
||||
async def get_miner_status_edevs(self) -> dict | None:
|
||||
return await self.send_command("get.miner.status", parameters="edevs")
|
||||
|
||||
async def get_miner_history(self) -> dict | None:
|
||||
data = await self.send_command(
|
||||
"get.miner.history",
|
||||
parameters={
|
||||
"start": "1",
|
||||
"stop": str(datetime.datetime.now().timestamp()),
|
||||
},
|
||||
)
|
||||
ret = {}
|
||||
result = data.get("msg")
|
||||
if result is not None:
|
||||
unparsed = result["Data"].strip()
|
||||
for item in unparsed.split(" "):
|
||||
list_item = item.split(",")
|
||||
timestamp = int(list_item.pop(0))
|
||||
ret[timestamp] = list_item
|
||||
return ret
|
||||
|
||||
async def get_psu_command(self):
|
||||
return await self.send_command("get.psu.command")
|
||||
|
||||
async def get_miner_setting(self) -> dict | None:
|
||||
return await self.send_command("get.miner.setting")
|
||||
|
||||
async def get_device_info(self) -> dict | None:
|
||||
return await self.send_command("get.device.info")
|
||||
|
||||
async def get_log_download(self) -> dict | None:
|
||||
return await self.send_command("get.log.download")
|
||||
|
||||
async def get_fan_setting(self) -> dict | None:
|
||||
return await self.send_command("get.fan.setting")
|
||||
|
||||
async def set_system_reboot(self) -> dict | None:
|
||||
return await self.send_command("set.system.reboot")
|
||||
|
||||
async def set_system_factory_reset(self, *args, **kwargs) -> dict | None:
|
||||
raise NotImplementedError
|
||||
return await self.send_command("set.system.factory_reset")
|
||||
|
||||
async def set_system_update_firmware(self, *args, **kwargs) -> dict | None:
|
||||
raise NotImplementedError
|
||||
return await self.send_command("set.system.update_firmware")
|
||||
|
||||
async def set_system_net_config(self, *args, **kwargs) -> dict | None:
|
||||
raise NotImplementedError
|
||||
return await self.send_command("set.system.net_config")
|
||||
|
||||
async def set_system_led(self, leds: list | None = None) -> dict | None:
|
||||
if leds is None:
|
||||
return await self.send_command("set.system.led", parameters="auto")
|
||||
else:
|
||||
return await self.send_command("set.system.led", parameters=leds)
|
||||
|
||||
async def set_system_time_randomized(self, *args, **kwargs) -> dict | None:
|
||||
raise NotImplementedError
|
||||
return await self.send_command("set.system.time_randomized")
|
||||
|
||||
async def set_system_timezone(self, *args, **kwargs) -> dict | None:
|
||||
raise NotImplementedError
|
||||
return await self.send_command("set.system.timezone")
|
||||
|
||||
async def set_system_hostname(self, *args, **kwargs) -> dict | None:
|
||||
raise NotImplementedError
|
||||
return await self.send_command("set.system.hostname")
|
||||
|
||||
async def set_system_webpools(self, *args, **kwargs) -> dict | None:
|
||||
raise NotImplementedError
|
||||
return await self.send_command("set.system.webpools")
|
||||
|
||||
async def set_miner_target_freq(self, *args, **kwargs) -> dict | None:
|
||||
raise NotImplementedError
|
||||
return await self.send_command("set.miner.target_freq")
|
||||
|
||||
async def set_miner_heat_mode(self, *args, **kwargs) -> dict | None:
|
||||
raise NotImplementedError
|
||||
return await self.send_command("set.miner.heat_mode")
|
||||
|
||||
async def set_system_ntp_server(self, *args, **kwargs) -> dict | None:
|
||||
raise NotImplementedError
|
||||
return await self.send_command("set.system.ntp_server")
|
||||
|
||||
async def set_miner_service(self, value: str) -> dict | None:
|
||||
return await self.send_command("set.miner.service", parameters=value)
|
||||
|
||||
async def set_miner_power_mode(self, *args, **kwargs) -> dict | None:
|
||||
raise NotImplementedError
|
||||
return await self.send_command("set.miner.power_mode")
|
||||
|
||||
async def set_miner_cointype(self, *args, **kwargs) -> dict | None:
|
||||
raise NotImplementedError
|
||||
return await self.send_command("set.miner.cointype")
|
||||
|
||||
async def set_miner_pools(self, *args, **kwargs) -> dict | None:
|
||||
raise NotImplementedError
|
||||
return await self.send_command("set.miner.pools")
|
||||
|
||||
async def set_miner_fastboot(self, *args, **kwargs) -> dict | None:
|
||||
raise NotImplementedError
|
||||
return await self.send_command("set.miner.fastboot")
|
||||
|
||||
async def set_miner_power_percent(self, *args, **kwargs) -> dict | None:
|
||||
raise NotImplementedError
|
||||
return await self.send_command("set.miner.power_percent")
|
||||
|
||||
async def set_miner_pre_power_on(self, *args, **kwargs) -> dict | None:
|
||||
raise NotImplementedError
|
||||
return await self.send_command("set.miner.pre_power_on")
|
||||
|
||||
async def set_miner_restore_setting(self, *args, **kwargs) -> dict | None:
|
||||
raise NotImplementedError
|
||||
return await self.send_command("set.miner.restore_setting")
|
||||
|
||||
async def set_miner_report(self, frequency: int = 1) -> dict | None:
|
||||
return await self.send_command(
|
||||
"set.miner.report", parameters={"gap": frequency}
|
||||
)
|
||||
|
||||
async def set_miner_power_limit(self, power: int) -> dict | None:
|
||||
return await self.send_command("set.miner.power_limit", parameters=power)
|
||||
|
||||
async def set_miner_upfreq_speed(self, *args, **kwargs) -> dict | None:
|
||||
raise NotImplementedError
|
||||
return await self.send_command("set.miner.upfreq_speed")
|
||||
|
||||
async def set_log_upload(self, *args, **kwargs) -> dict | None:
|
||||
raise NotImplementedError
|
||||
return await self.send_command("set.log.upload")
|
||||
|
||||
async def set_user_change_passwd(self, *args, **kwargs) -> dict | None:
|
||||
raise NotImplementedError
|
||||
return await self.send_command("set.user.change_passwd")
|
||||
|
||||
async def set_user_permission(self, *args, **kwargs) -> dict | None:
|
||||
raise NotImplementedError
|
||||
return await self.send_command("set.user.permission")
|
||||
|
||||
async def set_fan_temp_offset(self, *args, **kwargs) -> dict | None:
|
||||
raise NotImplementedError
|
||||
return await self.send_command("set.fan.temp_offset")
|
||||
|
||||
async def set_fan_poweroff_cool(self, *args, **kwargs) -> dict | None:
|
||||
raise NotImplementedError
|
||||
return await self.send_command("set.fan.poweroff_cool")
|
||||
|
||||
async def set_fan_zero_speed(self, *args, **kwargs) -> dict | None:
|
||||
raise NotImplementedError
|
||||
return await self.send_command("set.fan.zero_speed")
|
||||
|
||||
async def set_shell_debug(self, *args, **kwargs) -> dict | None:
|
||||
raise NotImplementedError
|
||||
return await self.send_command("set.shell.debug")
|
||||
|
||||
@@ -20,36 +20,34 @@ class ESPMinerWebAPI(BaseWebAPI):
|
||||
**parameters: Any,
|
||||
) -> dict:
|
||||
url = f"http://{self.ip}:{self.port}/api/{command}"
|
||||
async with httpx.AsyncClient(transport=settings.transport()) as client:
|
||||
for _ in range(settings.get("get_data_retries", 1)):
|
||||
try:
|
||||
if parameters.get("post", False):
|
||||
parameters.pop("post")
|
||||
data = await client.post(
|
||||
url,
|
||||
timeout=settings.get("api_function_timeout", 3),
|
||||
json=parameters,
|
||||
)
|
||||
elif parameters.get("patch", False):
|
||||
parameters.pop("patch")
|
||||
data = await client.patch(
|
||||
url,
|
||||
timeout=settings.get("api_function_timeout", 3),
|
||||
json=parameters,
|
||||
)
|
||||
else:
|
||||
data = await client.get(
|
||||
url,
|
||||
timeout=settings.get("api_function_timeout", 5),
|
||||
)
|
||||
except httpx.HTTPError:
|
||||
pass
|
||||
try:
|
||||
async with httpx.AsyncClient(
|
||||
transport=settings.transport(),
|
||||
) as client:
|
||||
if parameters.get("post", False):
|
||||
parameters.pop("post")
|
||||
data = await client.post(
|
||||
url,
|
||||
timeout=settings.get("api_function_timeout", 3),
|
||||
json=parameters,
|
||||
)
|
||||
elif parameters.get("patch", False):
|
||||
parameters.pop("patch")
|
||||
data = await client.patch(
|
||||
url,
|
||||
timeout=settings.get("api_function_timeout", 3),
|
||||
json=parameters,
|
||||
)
|
||||
else:
|
||||
if data.status_code == 200:
|
||||
try:
|
||||
return data.json()
|
||||
except json.decoder.JSONDecodeError:
|
||||
pass
|
||||
data = await client.get(url)
|
||||
except httpx.HTTPError:
|
||||
pass
|
||||
else:
|
||||
if data.status_code == 200:
|
||||
try:
|
||||
return data.json()
|
||||
except json.decoder.JSONDecodeError:
|
||||
pass
|
||||
|
||||
async def multicommand(
|
||||
self, *commands: str, ignore_errors: bool = False, allow_warning: bool = True
|
||||
@@ -96,6 +94,3 @@ class ESPMinerWebAPI(BaseWebAPI):
|
||||
|
||||
async def update_settings(self, **config):
|
||||
return await self.send_command("system", patch=True, **config)
|
||||
|
||||
async def asic_info(self):
|
||||
return await self.send_command("system/asic")
|
||||
|
||||
@@ -58,7 +58,7 @@ class VNishWebAPI(BaseWebAPI):
|
||||
allow_warning: bool = True,
|
||||
privileged: bool = False,
|
||||
**parameters: Any,
|
||||
) -> dict | None:
|
||||
) -> dict:
|
||||
post = privileged or not parameters == {}
|
||||
if self.token is None:
|
||||
await self.auth()
|
||||
@@ -126,9 +126,6 @@ class VNishWebAPI(BaseWebAPI):
|
||||
async def summary(self) -> dict:
|
||||
return await self.send_command("summary")
|
||||
|
||||
async def perf_summary(self) -> dict:
|
||||
return await self.send_command("perf-summary")
|
||||
|
||||
async def chips(self) -> dict:
|
||||
return await self.send_command("chips")
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[project]
|
||||
name = "pyasic"
|
||||
version = "0.75.2"
|
||||
version = "0.72.8"
|
||||
|
||||
description = "A simplified and standardized interface for Bitcoin ASICs."
|
||||
authors = [{name = "UpstreamData", email = "brett@upstreamdata.ca"}]
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user