Compare commits
25 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
29c2398846 | ||
|
|
ecc161820d | ||
|
|
5fec3052f6 | ||
|
|
437ee774ab | ||
|
|
aed9e0e406 | ||
|
|
be96428823 | ||
|
|
446881b237 | ||
|
|
ceab8e55b5 | ||
|
|
e12f85c94d | ||
|
|
0c85f53177 | ||
|
|
0b524f9bd0 | ||
|
|
95db852636 | ||
|
|
93fa02412a | ||
|
|
edb77e9cd8 | ||
|
|
cbf7eeb08d | ||
|
|
d34b35a82d | ||
|
|
5d57f35475 | ||
|
|
c95491ea45 | ||
|
|
e9ec43fac9 | ||
|
|
42bde081c4 | ||
|
|
bfb72aec1b | ||
|
|
b2f36b2f0b | ||
|
|
f75c07401b | ||
|
|
01b96227e0 | ||
|
|
82552390c8 |
@@ -53,6 +53,8 @@ def backend_str(backend: MinerTypes) -> str:
|
||||
return "Stock Firmware BitAxe Miners"
|
||||
case MinerTypes.ICERIVER:
|
||||
return "Stock Firmware IceRiver Miners"
|
||||
case MinerTypes.HAMMER:
|
||||
return "Stock Firmware Hammer Miners"
|
||||
|
||||
|
||||
def create_url_str(mtype: str):
|
||||
|
||||
@@ -358,6 +358,13 @@
|
||||
show_root_heading: false
|
||||
heading_level: 4
|
||||
|
||||
## S19j Pro (Stock)
|
||||
::: pyasic.miners.antminer.hiveon.X19.S19.HiveonS19jPro
|
||||
handler: python
|
||||
options:
|
||||
show_root_heading: false
|
||||
heading_level: 4
|
||||
|
||||
## S19 (LuxOS)
|
||||
::: pyasic.miners.antminer.luxos.X19.S19.LUXMinerS19
|
||||
handler: python
|
||||
|
||||
@@ -15,6 +15,13 @@
|
||||
show_root_heading: false
|
||||
heading_level: 4
|
||||
|
||||
## D7 (Stock)
|
||||
::: pyasic.miners.antminer.bmminer.X7.D7.BMMinerD7
|
||||
handler: python
|
||||
options:
|
||||
show_root_heading: false
|
||||
heading_level: 4
|
||||
|
||||
## L7 (VNish)
|
||||
::: pyasic.miners.antminer.vnish.X7.L7.VnishL7
|
||||
handler: python
|
||||
|
||||
@@ -8,6 +8,13 @@
|
||||
show_root_heading: false
|
||||
heading_level: 4
|
||||
|
||||
## D9 (Stock)
|
||||
::: pyasic.miners.antminer.bmminer.X9.D9.BMMinerD9
|
||||
handler: python
|
||||
options:
|
||||
show_root_heading: false
|
||||
heading_level: 4
|
||||
|
||||
## S9 (Stock)
|
||||
::: pyasic.miners.antminer.bmminer.X9.S9.BMMinerS9
|
||||
handler: python
|
||||
|
||||
@@ -22,3 +22,10 @@
|
||||
show_root_heading: false
|
||||
heading_level: 4
|
||||
|
||||
## Gamma (Stock)
|
||||
::: pyasic.miners.bitaxe.espminer.BM.BM1370.BitAxeGamma
|
||||
handler: python
|
||||
options:
|
||||
show_root_heading: false
|
||||
heading_level: 4
|
||||
|
||||
|
||||
10
docs/miners/hammer/DX.md
Normal file
10
docs/miners/hammer/DX.md
Normal file
@@ -0,0 +1,10 @@
|
||||
# pyasic
|
||||
## DX Models
|
||||
|
||||
## D10 (Stock)
|
||||
::: pyasic.miners.hammer.blackminer.DX.D10.HammerD10
|
||||
handler: python
|
||||
options:
|
||||
show_root_heading: false
|
||||
heading_level: 4
|
||||
|
||||
@@ -37,12 +37,14 @@ details {
|
||||
<ul>
|
||||
<li><a href="../antminer/X7#l7-stock">L7 (Stock)</a></li>
|
||||
<li><a href="../antminer/X7#k7-stock">K7 (Stock)</a></li>
|
||||
<li><a href="../antminer/X7#d7-stock">D7 (Stock)</a></li>
|
||||
</ul>
|
||||
</details>
|
||||
<details>
|
||||
<summary>X9 Series:</summary>
|
||||
<ul>
|
||||
<li><a href="../antminer/X9#e9pro-stock">E9Pro (Stock)</a></li>
|
||||
<li><a href="../antminer/X9#d9-stock">D9 (Stock)</a></li>
|
||||
<li><a href="../antminer/X9#s9-stock">S9 (Stock)</a></li>
|
||||
<li><a href="../antminer/X9#s9i-stock">S9i (Stock)</a></li>
|
||||
<li><a href="../antminer/X9#s9j-stock">S9j (Stock)</a></li>
|
||||
@@ -581,6 +583,12 @@ details {
|
||||
<li><a href="../antminer/X9#t9-stock">T9 (Stock)</a></li>
|
||||
</ul>
|
||||
</details>
|
||||
<details>
|
||||
<summary>X19 Series:</summary>
|
||||
<ul>
|
||||
<li><a href="../antminer/X19#s19j-pro-stock">S19j Pro (Stock)</a></li>
|
||||
</ul>
|
||||
</details>
|
||||
</ul>
|
||||
</details>
|
||||
<details>
|
||||
@@ -672,6 +680,7 @@ details {
|
||||
<li><a href="../bitaxe/BM#supra-stock">Supra (Stock)</a></li>
|
||||
<li><a href="../bitaxe/BM#ultra-stock">Ultra (Stock)</a></li>
|
||||
<li><a href="../bitaxe/BM#max-stock">Max (Stock)</a></li>
|
||||
<li><a href="../bitaxe/BM#gamma-stock">Gamma (Stock)</a></li>
|
||||
</ul>
|
||||
</details>
|
||||
</ul>
|
||||
@@ -694,4 +703,15 @@ details {
|
||||
</ul>
|
||||
</details>
|
||||
</ul>
|
||||
</details>
|
||||
<details>
|
||||
<summary>Stock Firmware Hammer Miners:</summary>
|
||||
<ul>
|
||||
<details>
|
||||
<summary>DX Series:</summary>
|
||||
<ul>
|
||||
<li><a href="../hammer/DX#d10-stock">D10 (Stock)</a></li>
|
||||
</ul>
|
||||
</details>
|
||||
</ul>
|
||||
</details>
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
from pyasic.config.fans import FanMode, FanModeConfig
|
||||
from pyasic.config.fans import FanMode, FanModeConfig, FanModeNormal
|
||||
from pyasic.config.mining import MiningMode, MiningModeConfig
|
||||
from pyasic.config.mining.scaling import ScalingConfig
|
||||
from pyasic.config.pools import PoolConfig
|
||||
@@ -28,6 +28,9 @@ class MinerConfig(BaseModel):
|
||||
"""Represents the configuration for a miner including pool configuration,
|
||||
fan mode, temperature settings, mining mode, and power scaling."""
|
||||
|
||||
class Config:
|
||||
arbitrary_types_allowed = True
|
||||
|
||||
pools: PoolConfig = Field(default_factory=PoolConfig.default)
|
||||
fan_mode: FanMode = Field(default_factory=FanModeConfig.default)
|
||||
temperature: TemperatureConfig = Field(default_factory=TemperatureConfig.default)
|
||||
@@ -156,6 +159,19 @@ class MinerConfig(BaseModel):
|
||||
**self.pools.as_luxos(user_suffix=user_suffix),
|
||||
}
|
||||
|
||||
def as_vnish(self, user_suffix: str = None) -> dict:
|
||||
main_cfg = {
|
||||
"miner": {
|
||||
**self.fan_mode.as_vnish(),
|
||||
**self.temperature.as_vnish(),
|
||||
**self.mining_mode.as_vnish(),
|
||||
**self.pools.as_vnish(user_suffix=user_suffix),
|
||||
}
|
||||
}
|
||||
if isinstance(self.fan_mode, FanModeNormal):
|
||||
main_cfg["miner"]["cooling"]["mode"]["param"] = self.temperature.target
|
||||
return main_cfg
|
||||
|
||||
def as_hammer(self, *args, **kwargs) -> dict:
|
||||
return self.as_am_modern(*args, **kwargs)
|
||||
|
||||
|
||||
@@ -87,6 +87,18 @@ class FanModeNormal(MinerConfigValue):
|
||||
def as_luxos(self) -> dict:
|
||||
return {"fanset": {"speed": -1, "min_fans": self.minimum_fans}}
|
||||
|
||||
def as_vnish(self) -> dict:
|
||||
return {
|
||||
"cooling": {
|
||||
"fan_min_count": self.minimum_fans,
|
||||
"fan_min_duty": self.minimum_speed,
|
||||
"mode": {
|
||||
"name": "auto",
|
||||
"param": None, # Target temp, must be set later...
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class FanModeManual(MinerConfigValue):
|
||||
mode: str = Field(init=False, default="manual")
|
||||
@@ -150,6 +162,18 @@ class FanModeManual(MinerConfigValue):
|
||||
def as_luxos(self) -> dict:
|
||||
return {"fanset": {"speed": self.speed, "min_fans": self.minimum_fans}}
|
||||
|
||||
def as_vnish(self) -> dict:
|
||||
return {
|
||||
"cooling": {
|
||||
"fan_min_count": self.minimum_fans,
|
||||
"fan_min_duty": self.speed,
|
||||
"mode": {
|
||||
"name": "manual",
|
||||
"param": self.speed, # Speed value
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class FanModeImmersion(MinerConfigValue):
|
||||
mode: str = Field(init=False, default="immersion")
|
||||
@@ -175,6 +199,9 @@ class FanModeImmersion(MinerConfigValue):
|
||||
def as_luxos(self) -> dict:
|
||||
return {"fanset": {"speed": 0, "min_fans": 0}}
|
||||
|
||||
def as_vnish(self) -> dict:
|
||||
return {"cooling": {"mode": {"name": "immers"}}}
|
||||
|
||||
|
||||
class FanModeConfig(MinerConfigOption):
|
||||
normal = FanModeNormal
|
||||
@@ -336,4 +363,7 @@ class FanModeConfig(MinerConfigOption):
|
||||
return cls.default()
|
||||
|
||||
|
||||
FanMode = TypeVar("FanMode", bound=Union[*[v.value for v in FanModeConfig]])
|
||||
FanMode = TypeVar(
|
||||
"FanMode",
|
||||
bound=Union[FanModeNormal, FanModeManual, FanModeImmersion],
|
||||
)
|
||||
|
||||
@@ -148,6 +148,9 @@ class MiningModeHPM(MinerConfigValue):
|
||||
|
||||
|
||||
class MiningModePowerTune(MinerConfigValue):
|
||||
class Config:
|
||||
arbitrary_types_allowed = True
|
||||
|
||||
mode: str = field(init=False, default="power_tuning")
|
||||
power: int | None = None
|
||||
algo: TunerAlgoType = field(default_factory=TunerAlgo.default)
|
||||
@@ -244,6 +247,9 @@ class MiningModePowerTune(MinerConfigValue):
|
||||
|
||||
|
||||
class MiningModeHashrateTune(MinerConfigValue):
|
||||
class Config:
|
||||
arbitrary_types_allowed = True
|
||||
|
||||
mode: str = field(init=False, default="hashrate_tuning")
|
||||
hashrate: int = None
|
||||
algo: TunerAlgoType = field(default_factory=TunerAlgo.default)
|
||||
@@ -351,6 +357,9 @@ class ManualBoardSettings(MinerConfigValue):
|
||||
return {"miner-mode": "0"}
|
||||
return {"miner-mode": 0}
|
||||
|
||||
def as_vnish(self) -> dict:
|
||||
return {"freq": self.freq}
|
||||
|
||||
|
||||
class MiningModeManual(MinerConfigValue):
|
||||
mode: str = field(init=False, default="manual")
|
||||
@@ -372,6 +381,17 @@ class MiningModeManual(MinerConfigValue):
|
||||
return {"miner-mode": "0"}
|
||||
return {"miner-mode": 0}
|
||||
|
||||
def as_vnish(self) -> dict:
|
||||
return {
|
||||
"overclock": {
|
||||
"chains": [b.as_vnish() for b in self.boards.values() if b.freq != 0],
|
||||
"globals": {
|
||||
"freq": int(self.global_freq),
|
||||
"volt": int(self.global_volt),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@classmethod
|
||||
def from_vnish(cls, web_overclock_settings: dict) -> "MiningModeManual":
|
||||
# will raise KeyError if it cant find the settings, values cannot be empty
|
||||
@@ -642,4 +662,15 @@ class MiningModeConfig(MinerConfigOption):
|
||||
return cls.default()
|
||||
|
||||
|
||||
MiningMode = TypeVar("MiningMode", bound=Union[*[v.value for v in MiningModeConfig]])
|
||||
MiningMode = TypeVar(
|
||||
"MiningMode",
|
||||
bound=Union[
|
||||
MiningModeNormal,
|
||||
MiningModeHPM,
|
||||
MiningModeLPM,
|
||||
MiningModeSleep,
|
||||
MiningModeManual,
|
||||
MiningModePowerTune,
|
||||
MiningModeHashrateTune,
|
||||
],
|
||||
)
|
||||
|
||||
@@ -55,4 +55,12 @@ class TunerAlgo(MinerConfigOption):
|
||||
return cls_attr().from_dict(dict_conf)
|
||||
|
||||
|
||||
TunerAlgoType = TypeVar("TunerAlgoType", bound=Union[*[v.value for v in TunerAlgo]])
|
||||
TunerAlgoType = TypeVar(
|
||||
"TunerAlgoType",
|
||||
bound=Union[
|
||||
StandardTuneAlgo,
|
||||
VOptAlgo,
|
||||
BoardTuneAlgo,
|
||||
ChipTuneAlgo,
|
||||
],
|
||||
)
|
||||
|
||||
@@ -146,6 +146,15 @@ class Pool(MinerConfigValue):
|
||||
url=self.url, user=self.user, password=self.password, enabled=True
|
||||
)
|
||||
|
||||
def as_vnish(self, user_suffix: str = None) -> dict:
|
||||
if user_suffix is not None:
|
||||
return {
|
||||
"url": self.url,
|
||||
"user": f"{self.user}{user_suffix}",
|
||||
"pass": self.password,
|
||||
}
|
||||
return {"url": self.url, "user": self.user, "pass": self.password}
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, dict_conf: dict | None) -> "Pool":
|
||||
return cls(
|
||||
@@ -338,6 +347,9 @@ class PoolGroup(MinerConfigValue):
|
||||
pools=[p.as_boser() for p in self.pools],
|
||||
)
|
||||
|
||||
def as_vnish(self, user_suffix: str = None) -> dict:
|
||||
return {"pools": [p.as_vnish(user_suffix=user_suffix) for p in self.pools]}
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, dict_conf: dict | None) -> "PoolGroup":
|
||||
cls_conf = {}
|
||||
@@ -530,6 +542,9 @@ class PoolConfig(MinerConfigValue):
|
||||
def as_luxos(self, user_suffix: str = None) -> dict:
|
||||
return {}
|
||||
|
||||
def as_vnish(self, user_suffix: str = None) -> dict:
|
||||
return self.groups[0].as_vnish(user_suffix=user_suffix)
|
||||
|
||||
@classmethod
|
||||
def from_api(cls, api_pools: dict) -> "PoolConfig":
|
||||
try:
|
||||
|
||||
@@ -56,6 +56,9 @@ class TemperatureConfig(MinerConfigValue):
|
||||
def as_luxos(self) -> dict:
|
||||
return {"tempctrlset": [self.target or "", self.hot or "", self.danger or ""]}
|
||||
|
||||
def as_vnish(self) -> dict:
|
||||
return {"misc": {"restart_temp": self.danger}}
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, dict_conf: dict | None) -> "TemperatureConfig":
|
||||
return cls(
|
||||
@@ -95,9 +98,16 @@ class TemperatureConfig(MinerConfigValue):
|
||||
|
||||
@classmethod
|
||||
def from_vnish(cls, web_settings: dict) -> "TemperatureConfig":
|
||||
try:
|
||||
dangerous_temp = web_settings["misc"]["restart_temp"]
|
||||
except KeyError:
|
||||
dangerous_temp = None
|
||||
try:
|
||||
if web_settings["miner"]["cooling"]["mode"]["name"] == "auto":
|
||||
return cls(target=web_settings["miner"]["cooling"]["mode"]["param"])
|
||||
return cls(
|
||||
target=web_settings["miner"]["cooling"]["mode"]["param"],
|
||||
danger=dangerous_temp,
|
||||
)
|
||||
except KeyError:
|
||||
pass
|
||||
return cls()
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
# See the License for the specific language governing permissions and -
|
||||
# limitations under the License. -
|
||||
# ------------------------------------------------------------------------------
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
@@ -40,8 +41,8 @@ class HashBoard(BaseModel):
|
||||
|
||||
slot: int = 0
|
||||
hashrate: AlgoHashRateType | None = None
|
||||
temp: int | None = None
|
||||
chip_temp: int | None = None
|
||||
temp: float | None = None
|
||||
chip_temp: float | None = None
|
||||
chips: int | None = None
|
||||
expected_chips: int | None = None
|
||||
serial_number: str | None = None
|
||||
|
||||
@@ -12,7 +12,7 @@ class DeviceInfo(BaseModel):
|
||||
make: MinerMake | None = None
|
||||
model: MinerModelType | None = None
|
||||
firmware: MinerFirmware | None = None
|
||||
algo: MinerAlgoType | None = None
|
||||
algo: type[MinerAlgoType] | None = None
|
||||
|
||||
@field_serializer("make")
|
||||
def serialize_make(self, make: MinerMake, _info):
|
||||
|
||||
@@ -3,6 +3,7 @@ from typing import Optional
|
||||
from urllib.parse import urlparse
|
||||
|
||||
from pydantic import BaseModel, computed_field, model_serializer
|
||||
from typing_extensions import Self
|
||||
|
||||
|
||||
class Scheme(Enum):
|
||||
@@ -28,8 +29,10 @@ class PoolUrl(BaseModel):
|
||||
return f"{self.scheme.value}://{self.host}:{self.port}"
|
||||
|
||||
@classmethod
|
||||
def from_str(cls, url: str) -> "PoolUrl":
|
||||
def from_str(cls, url: str) -> Self | None:
|
||||
parsed_url = urlparse(url)
|
||||
if not parsed_url.hostname:
|
||||
return None
|
||||
if not parsed_url.scheme.strip() == "":
|
||||
scheme = Scheme(parsed_url.scheme)
|
||||
else:
|
||||
@@ -57,15 +60,15 @@ class PoolMetrics(BaseModel):
|
||||
pool_stale_percent: Percentage of stale shares by the pool.
|
||||
"""
|
||||
|
||||
url: PoolUrl
|
||||
accepted: int = None
|
||||
rejected: int = None
|
||||
get_failures: int = None
|
||||
remote_failures: int = None
|
||||
active: bool = None
|
||||
alive: bool = None
|
||||
index: int = None
|
||||
user: str = None
|
||||
url: PoolUrl | None
|
||||
accepted: int | None = None
|
||||
rejected: int | None = None
|
||||
get_failures: int | None = None
|
||||
remote_failures: int | None = None
|
||||
active: bool | None = None
|
||||
alive: bool | None = None
|
||||
index: int | None = None
|
||||
user: str | None = None
|
||||
|
||||
@computed_field # type: ignore[misc]
|
||||
@property
|
||||
|
||||
@@ -4,6 +4,13 @@ from .hashrate.base import AlgoHashRateType
|
||||
from .hashrate.unit.base import AlgoHashRateUnitType
|
||||
|
||||
|
||||
class MinerAlgoType(str):
|
||||
class MinerAlgoMeta(type):
|
||||
name: str
|
||||
|
||||
def __str__(cls):
|
||||
return cls.name
|
||||
|
||||
|
||||
class MinerAlgoType(metaclass=MinerAlgoMeta):
|
||||
hashrate: type[AlgoHashRateType]
|
||||
unit: type[AlgoHashRateUnitType]
|
||||
|
||||
@@ -6,12 +6,8 @@ from .hashrate.unit import Blake256Unit
|
||||
|
||||
|
||||
# make this json serializable
|
||||
class _Blake256Algo(MinerAlgoType):
|
||||
hashrate = Blake256HashRate
|
||||
unit = Blake256Unit
|
||||
class Blake256Algo(MinerAlgoType):
|
||||
hashrate: type[Blake256HashRate] = Blake256HashRate
|
||||
unit: type[Blake256Unit] = Blake256Unit
|
||||
|
||||
def __repr__(self):
|
||||
return "Blake256Algo"
|
||||
|
||||
|
||||
Blake256Algo = _Blake256Algo("Blake256")
|
||||
name = "Blake256"
|
||||
|
||||
@@ -6,12 +6,8 @@ from .hashrate.unit import EaglesongUnit
|
||||
|
||||
|
||||
# make this json serializable
|
||||
class _EaglesongAlgo(MinerAlgoType):
|
||||
hashrate = EaglesongHashRate
|
||||
unit = EaglesongUnit
|
||||
class EaglesongAlgo(MinerAlgoType):
|
||||
hashrate: type[EaglesongHashRate] = EaglesongHashRate
|
||||
unit: type[EaglesongUnit] = EaglesongUnit
|
||||
|
||||
def __repr__(self):
|
||||
return "EaglesongAlgo"
|
||||
|
||||
|
||||
EaglesongAlgo = _EaglesongAlgo("Eaglesong")
|
||||
name = "Eaglesong"
|
||||
|
||||
@@ -6,12 +6,8 @@ from .hashrate.unit import EquihashUnit
|
||||
|
||||
|
||||
# make this json serializable
|
||||
class _EquihashAlgo(MinerAlgoType):
|
||||
hashrate = EquihashHashRate
|
||||
unit = EquihashUnit
|
||||
class EquihashAlgo(MinerAlgoType):
|
||||
hashrate: type[EquihashHashRate] = EquihashHashRate
|
||||
unit: type[EquihashUnit] = EquihashUnit
|
||||
|
||||
def __repr__(self):
|
||||
return "EquihashAlgo"
|
||||
|
||||
|
||||
EquihashAlgo = _EquihashAlgo("Equihash")
|
||||
name = "Equihash"
|
||||
|
||||
@@ -5,13 +5,8 @@ from .hashrate import EtHashHashRate
|
||||
from .hashrate.unit import EtHashUnit
|
||||
|
||||
|
||||
# make this json serializable
|
||||
class _EtHashAlgo(MinerAlgoType):
|
||||
hashrate = EtHashHashRate
|
||||
unit = EtHashUnit
|
||||
class EtHashAlgo(MinerAlgoType):
|
||||
hashrate: type[EtHashHashRate] = EtHashHashRate
|
||||
unit: type[EtHashUnit] = EtHashUnit
|
||||
|
||||
def __repr__(self):
|
||||
return "EtHashAlgo"
|
||||
|
||||
|
||||
EtHashAlgo = _EtHashAlgo("EtHash")
|
||||
name = "EtHash"
|
||||
|
||||
@@ -6,12 +6,8 @@ from .hashrate.unit import HandshakeUnit
|
||||
|
||||
|
||||
# make this json serializable
|
||||
class _HandshakeAlgo(MinerAlgoType):
|
||||
hashrate = HandshakeHashRate
|
||||
unit = HandshakeUnit
|
||||
class HandshakeAlgo(MinerAlgoType):
|
||||
hashrate: type[HandshakeHashRate] = HandshakeHashRate
|
||||
unit: type[HandshakeUnit] = HandshakeUnit
|
||||
|
||||
def __repr__(self):
|
||||
return "HandshakeAlgo"
|
||||
|
||||
|
||||
HandshakeAlgo = _HandshakeAlgo("Handshake")
|
||||
name = "Handshake"
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from abc import ABC, abstractmethod
|
||||
|
||||
from pydantic import BaseModel
|
||||
from typing_extensions import Self
|
||||
|
||||
from .unit.base import AlgoHashRateUnitType
|
||||
|
||||
@@ -24,3 +25,38 @@ class AlgoHashRateType(BaseModel, ABC):
|
||||
|
||||
def __round__(self, n: int = None):
|
||||
return round(self.rate, n)
|
||||
|
||||
def __add__(self, other: Self | int | float) -> Self:
|
||||
if isinstance(other, self.__class__):
|
||||
return self.__class__(
|
||||
rate=self.rate + other.into(self.unit).rate, unit=self.unit
|
||||
)
|
||||
return self.__class__(rate=self.rate + other, unit=self.unit)
|
||||
|
||||
def __sub__(self, other: Self | int | float) -> Self:
|
||||
if isinstance(other, self.__class__):
|
||||
return self.__class__(
|
||||
rate=self.rate - other.into(self.unit).rate, unit=self.unit
|
||||
)
|
||||
return self.__class__(rate=self.rate - other, unit=self.unit)
|
||||
|
||||
def __truediv__(self, other: Self | int | float) -> Self:
|
||||
if isinstance(other, self.__class__):
|
||||
return self.__class__(
|
||||
rate=self.rate / other.into(self.unit).rate, unit=self.unit
|
||||
)
|
||||
return self.__class__(rate=self.rate / other, unit=self.unit)
|
||||
|
||||
def __floordiv__(self, other: Self | int | float) -> Self:
|
||||
if isinstance(other, self.__class__):
|
||||
return self.__class__(
|
||||
rate=self.rate // other.into(self.unit).rate, unit=self.unit
|
||||
)
|
||||
return self.__class__(rate=self.rate // other, unit=self.unit)
|
||||
|
||||
def __mul__(self, other: Self | int | float) -> Self:
|
||||
if isinstance(other, self.__class__):
|
||||
return self.__class__(
|
||||
rate=self.rate * other.into(self.unit).rate, unit=self.unit
|
||||
)
|
||||
return self.__class__(rate=self.rate * other, unit=self.unit)
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing_extensions import Self
|
||||
|
||||
from pyasic.device.algorithm.hashrate.base import AlgoHashRateType
|
||||
from pyasic.device.algorithm.hashrate.unit.blake256 import Blake256Unit
|
||||
|
||||
@@ -10,42 +12,7 @@ class Blake256HashRate(AlgoHashRateType):
|
||||
rate: float
|
||||
unit: Blake256Unit = HashUnit.BLAKE256.default
|
||||
|
||||
def __add__(self, other: Blake256HashRate | int | float) -> Blake256HashRate:
|
||||
if isinstance(other, Blake256HashRate):
|
||||
return Blake256HashRate(
|
||||
rate=self.rate + other.into(self.unit).rate, unit=self.unit
|
||||
)
|
||||
return Blake256HashRate(rate=self.rate + other, unit=self.unit)
|
||||
|
||||
def __sub__(self, other: Blake256HashRate | int | float) -> Blake256HashRate:
|
||||
if isinstance(other, Blake256HashRate):
|
||||
return Blake256HashRate(
|
||||
rate=self.rate - other.into(self.unit).rate, unit=self.unit
|
||||
)
|
||||
return Blake256HashRate(rate=self.rate - other, unit=self.unit)
|
||||
|
||||
def __truediv__(self, other: Blake256HashRate | int | float):
|
||||
if isinstance(other, Blake256HashRate):
|
||||
return Blake256HashRate(
|
||||
rate=self.rate / other.into(self.unit).rate, unit=self.unit
|
||||
)
|
||||
return Blake256HashRate(rate=self.rate / other, unit=self.unit)
|
||||
|
||||
def __floordiv__(self, other: Blake256HashRate | int | float):
|
||||
if isinstance(other, Blake256HashRate):
|
||||
return Blake256HashRate(
|
||||
rate=self.rate // other.into(self.unit).rate, unit=self.unit
|
||||
)
|
||||
return Blake256HashRate(rate=self.rate // other, unit=self.unit)
|
||||
|
||||
def __mul__(self, other: Blake256HashRate | int | float):
|
||||
if isinstance(other, Blake256HashRate):
|
||||
return Blake256HashRate(
|
||||
rate=self.rate * other.into(self.unit).rate, unit=self.unit
|
||||
)
|
||||
return Blake256HashRate(rate=self.rate * other, unit=self.unit)
|
||||
|
||||
def into(self, other: Blake256Unit) -> Blake256HashRate:
|
||||
return Blake256HashRate(
|
||||
def into(self, other: Blake256Unit) -> Self:
|
||||
return self.__class__(
|
||||
rate=self.rate / (other.value / self.unit.value), unit=other
|
||||
)
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing_extensions import Self
|
||||
|
||||
from pyasic.device.algorithm.hashrate.base import AlgoHashRateType
|
||||
from pyasic.device.algorithm.hashrate.unit.eaglesong import EaglesongUnit
|
||||
|
||||
@@ -10,42 +12,7 @@ class EaglesongHashRate(AlgoHashRateType):
|
||||
rate: float
|
||||
unit: EaglesongUnit = HashUnit.EAGLESONG.default
|
||||
|
||||
def __add__(self, other: EaglesongHashRate | int | float) -> EaglesongHashRate:
|
||||
if isinstance(other, EaglesongHashRate):
|
||||
return EaglesongHashRate(
|
||||
rate=self.rate + other.into(self.unit).rate, unit=self.unit
|
||||
)
|
||||
return EaglesongHashRate(rate=self.rate + other, unit=self.unit)
|
||||
|
||||
def __sub__(self, other: EaglesongHashRate | int | float) -> EaglesongHashRate:
|
||||
if isinstance(other, EaglesongHashRate):
|
||||
return EaglesongHashRate(
|
||||
rate=self.rate - other.into(self.unit).rate, unit=self.unit
|
||||
)
|
||||
return EaglesongHashRate(rate=self.rate - other, unit=self.unit)
|
||||
|
||||
def __truediv__(self, other: EaglesongHashRate | int | float):
|
||||
if isinstance(other, EaglesongHashRate):
|
||||
return EaglesongHashRate(
|
||||
rate=self.rate / other.into(self.unit).rate, unit=self.unit
|
||||
)
|
||||
return EaglesongHashRate(rate=self.rate / other, unit=self.unit)
|
||||
|
||||
def __floordiv__(self, other: EaglesongHashRate | int | float):
|
||||
if isinstance(other, EaglesongHashRate):
|
||||
return EaglesongHashRate(
|
||||
rate=self.rate // other.into(self.unit).rate, unit=self.unit
|
||||
)
|
||||
return EaglesongHashRate(rate=self.rate // other, unit=self.unit)
|
||||
|
||||
def __mul__(self, other: EaglesongHashRate | int | float):
|
||||
if isinstance(other, EaglesongHashRate):
|
||||
return EaglesongHashRate(
|
||||
rate=self.rate * other.into(self.unit).rate, unit=self.unit
|
||||
)
|
||||
return EaglesongHashRate(rate=self.rate * other, unit=self.unit)
|
||||
|
||||
def into(self, other: EaglesongUnit) -> EaglesongHashRate:
|
||||
return EaglesongHashRate(
|
||||
def into(self, other: EaglesongUnit) -> Self:
|
||||
return self.__class__(
|
||||
rate=self.rate / (other.value / self.unit.value), unit=other
|
||||
)
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing_extensions import Self
|
||||
|
||||
from pyasic.device.algorithm.hashrate.base import AlgoHashRateType
|
||||
from pyasic.device.algorithm.hashrate.unit.equihash import EquihashUnit
|
||||
|
||||
@@ -10,42 +12,7 @@ class EquihashHashRate(AlgoHashRateType):
|
||||
rate: float
|
||||
unit: EquihashUnit = HashUnit.ETHASH.default
|
||||
|
||||
def __add__(self, other: EquihashHashRate | int | float) -> EquihashHashRate:
|
||||
if isinstance(other, EquihashHashRate):
|
||||
return EquihashHashRate(
|
||||
rate=self.rate + other.into(self.unit).rate, unit=self.unit
|
||||
)
|
||||
return EquihashHashRate(rate=self.rate + other, unit=self.unit)
|
||||
|
||||
def __sub__(self, other: EquihashHashRate | int | float) -> EquihashHashRate:
|
||||
if isinstance(other, EquihashHashRate):
|
||||
return EquihashHashRate(
|
||||
rate=self.rate - other.into(self.unit).rate, unit=self.unit
|
||||
)
|
||||
return EquihashHashRate(rate=self.rate - other, unit=self.unit)
|
||||
|
||||
def __truediv__(self, other: EquihashHashRate | int | float):
|
||||
if isinstance(other, EquihashHashRate):
|
||||
return EquihashHashRate(
|
||||
rate=self.rate / other.into(self.unit).rate, unit=self.unit
|
||||
)
|
||||
return EquihashHashRate(rate=self.rate / other, unit=self.unit)
|
||||
|
||||
def __floordiv__(self, other: EquihashHashRate | int | float):
|
||||
if isinstance(other, EquihashHashRate):
|
||||
return EquihashHashRate(
|
||||
rate=self.rate // other.into(self.unit).rate, unit=self.unit
|
||||
)
|
||||
return EquihashHashRate(rate=self.rate // other, unit=self.unit)
|
||||
|
||||
def __mul__(self, other: EquihashHashRate | int | float):
|
||||
if isinstance(other, EquihashHashRate):
|
||||
return EquihashHashRate(
|
||||
rate=self.rate * other.into(self.unit).rate, unit=self.unit
|
||||
)
|
||||
return EquihashHashRate(rate=self.rate * other, unit=self.unit)
|
||||
|
||||
def into(self, other: EquihashUnit) -> EquihashHashRate:
|
||||
return EquihashHashRate(
|
||||
def into(self, other: EquihashUnit) -> Self:
|
||||
return self.__class__(
|
||||
rate=self.rate / (other.value / self.unit.value), unit=other
|
||||
)
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing_extensions import Self
|
||||
|
||||
from pyasic.device.algorithm.hashrate.base import AlgoHashRateType
|
||||
from pyasic.device.algorithm.hashrate.unit.ethash import EtHashUnit
|
||||
|
||||
@@ -10,42 +12,7 @@ class EtHashHashRate(AlgoHashRateType):
|
||||
rate: float
|
||||
unit: EtHashUnit = HashUnit.ETHASH.default
|
||||
|
||||
def __add__(self, other: EtHashHashRate | int | float) -> EtHashHashRate:
|
||||
if isinstance(other, EtHashHashRate):
|
||||
return EtHashHashRate(
|
||||
rate=self.rate + other.into(self.unit).rate, unit=self.unit
|
||||
)
|
||||
return EtHashHashRate(rate=self.rate + other, unit=self.unit)
|
||||
|
||||
def __sub__(self, other: EtHashHashRate | int | float) -> EtHashHashRate:
|
||||
if isinstance(other, EtHashHashRate):
|
||||
return EtHashHashRate(
|
||||
rate=self.rate - other.into(self.unit).rate, unit=self.unit
|
||||
)
|
||||
return EtHashHashRate(rate=self.rate - other, unit=self.unit)
|
||||
|
||||
def __truediv__(self, other: EtHashHashRate | int | float):
|
||||
if isinstance(other, EtHashHashRate):
|
||||
return EtHashHashRate(
|
||||
rate=self.rate / other.into(self.unit).rate, unit=self.unit
|
||||
)
|
||||
return EtHashHashRate(rate=self.rate / other, unit=self.unit)
|
||||
|
||||
def __floordiv__(self, other: EtHashHashRate | int | float):
|
||||
if isinstance(other, EtHashHashRate):
|
||||
return EtHashHashRate(
|
||||
rate=self.rate // other.into(self.unit).rate, unit=self.unit
|
||||
)
|
||||
return EtHashHashRate(rate=self.rate // other, unit=self.unit)
|
||||
|
||||
def __mul__(self, other: EtHashHashRate | int | float):
|
||||
if isinstance(other, EtHashHashRate):
|
||||
return EtHashHashRate(
|
||||
rate=self.rate * other.into(self.unit).rate, unit=self.unit
|
||||
)
|
||||
return EtHashHashRate(rate=self.rate * other, unit=self.unit)
|
||||
|
||||
def into(self, other: EtHashUnit) -> EtHashHashRate:
|
||||
return EtHashHashRate(
|
||||
def into(self, other: EtHashUnit) -> Self:
|
||||
return self.__class__(
|
||||
rate=self.rate / (other.value / self.unit.value), unit=other
|
||||
)
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing_extensions import Self
|
||||
|
||||
from pyasic.device.algorithm.hashrate.base import AlgoHashRateType
|
||||
from pyasic.device.algorithm.hashrate.unit.handshake import HandshakeUnit
|
||||
|
||||
@@ -10,42 +12,7 @@ class HandshakeHashRate(AlgoHashRateType):
|
||||
rate: float
|
||||
unit: HandshakeUnit = HashUnit.HANDSHAKE.default
|
||||
|
||||
def __add__(self, other: HandshakeHashRate | int | float) -> HandshakeHashRate:
|
||||
if isinstance(other, HandshakeHashRate):
|
||||
return HandshakeHashRate(
|
||||
rate=self.rate + other.into(self.unit).rate, unit=self.unit
|
||||
)
|
||||
return HandshakeHashRate(rate=self.rate + other, unit=self.unit)
|
||||
|
||||
def __sub__(self, other: HandshakeHashRate | int | float) -> HandshakeHashRate:
|
||||
if isinstance(other, HandshakeHashRate):
|
||||
return HandshakeHashRate(
|
||||
rate=self.rate - other.into(self.unit).rate, unit=self.unit
|
||||
)
|
||||
return HandshakeHashRate(rate=self.rate - other, unit=self.unit)
|
||||
|
||||
def __truediv__(self, other: HandshakeHashRate | int | float):
|
||||
if isinstance(other, HandshakeHashRate):
|
||||
return HandshakeHashRate(
|
||||
rate=self.rate / other.into(self.unit).rate, unit=self.unit
|
||||
)
|
||||
return HandshakeHashRate(rate=self.rate / other, unit=self.unit)
|
||||
|
||||
def __floordiv__(self, other: HandshakeHashRate | int | float):
|
||||
if isinstance(other, HandshakeHashRate):
|
||||
return HandshakeHashRate(
|
||||
rate=self.rate // other.into(self.unit).rate, unit=self.unit
|
||||
)
|
||||
return HandshakeHashRate(rate=self.rate // other, unit=self.unit)
|
||||
|
||||
def __mul__(self, other: HandshakeHashRate | int | float):
|
||||
if isinstance(other, HandshakeHashRate):
|
||||
return HandshakeHashRate(
|
||||
rate=self.rate * other.into(self.unit).rate, unit=self.unit
|
||||
)
|
||||
return HandshakeHashRate(rate=self.rate * other, unit=self.unit)
|
||||
|
||||
def into(self, other: HandshakeUnit) -> HandshakeHashRate:
|
||||
return HandshakeHashRate(
|
||||
def into(self, other: HandshakeUnit) -> Self:
|
||||
return self.__class__(
|
||||
rate=self.rate / (other.value / self.unit.value), unit=other
|
||||
)
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing_extensions import Self
|
||||
|
||||
from pyasic.device.algorithm.hashrate.base import AlgoHashRateType
|
||||
from pyasic.device.algorithm.hashrate.unit.kadena import KadenaUnit
|
||||
|
||||
@@ -10,42 +12,7 @@ class KadenaHashRate(AlgoHashRateType):
|
||||
rate: float
|
||||
unit: KadenaUnit = HashUnit.KADENA.default
|
||||
|
||||
def __add__(self, other: KadenaHashRate | int | float) -> KadenaHashRate:
|
||||
if isinstance(other, KadenaHashRate):
|
||||
return KadenaHashRate(
|
||||
rate=self.rate + other.into(self.unit).rate, unit=self.unit
|
||||
)
|
||||
return KadenaHashRate(rate=self.rate + other, unit=self.unit)
|
||||
|
||||
def __sub__(self, other: KadenaHashRate | int | float) -> KadenaHashRate:
|
||||
if isinstance(other, KadenaHashRate):
|
||||
return KadenaHashRate(
|
||||
rate=self.rate - other.into(self.unit).rate, unit=self.unit
|
||||
)
|
||||
return KadenaHashRate(rate=self.rate - other, unit=self.unit)
|
||||
|
||||
def __truediv__(self, other: KadenaHashRate | int | float):
|
||||
if isinstance(other, KadenaHashRate):
|
||||
return KadenaHashRate(
|
||||
rate=self.rate / other.into(self.unit).rate, unit=self.unit
|
||||
)
|
||||
return KadenaHashRate(rate=self.rate / other, unit=self.unit)
|
||||
|
||||
def __floordiv__(self, other: KadenaHashRate | int | float):
|
||||
if isinstance(other, KadenaHashRate):
|
||||
return KadenaHashRate(
|
||||
rate=self.rate // other.into(self.unit).rate, unit=self.unit
|
||||
)
|
||||
return KadenaHashRate(rate=self.rate // other, unit=self.unit)
|
||||
|
||||
def __mul__(self, other: KadenaHashRate | int | float):
|
||||
if isinstance(other, KadenaHashRate):
|
||||
return KadenaHashRate(
|
||||
rate=self.rate * other.into(self.unit).rate, unit=self.unit
|
||||
)
|
||||
return KadenaHashRate(rate=self.rate * other, unit=self.unit)
|
||||
|
||||
def into(self, other: KadenaUnit) -> KadenaHashRate:
|
||||
return KadenaHashRate(
|
||||
def into(self, other: KadenaUnit) -> Self:
|
||||
return self.__class__(
|
||||
rate=self.rate / (other.value / self.unit.value), unit=other
|
||||
)
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing_extensions import Self
|
||||
|
||||
from pyasic.device.algorithm.hashrate.base import AlgoHashRateType
|
||||
from pyasic.device.algorithm.hashrate.unit.kheavyhash import KHeavyHashUnit
|
||||
|
||||
@@ -10,42 +12,7 @@ class KHeavyHashHashRate(AlgoHashRateType):
|
||||
rate: float
|
||||
unit: KHeavyHashUnit = HashUnit.KHEAVYHASH.default
|
||||
|
||||
def __add__(self, other: KHeavyHashHashRate | int | float) -> KHeavyHashHashRate:
|
||||
if isinstance(other, KHeavyHashHashRate):
|
||||
return KHeavyHashHashRate(
|
||||
rate=self.rate + other.into(self.unit).rate, unit=self.unit
|
||||
)
|
||||
return KHeavyHashHashRate(rate=self.rate + other, unit=self.unit)
|
||||
|
||||
def __sub__(self, other: KHeavyHashHashRate | int | float) -> KHeavyHashHashRate:
|
||||
if isinstance(other, KHeavyHashHashRate):
|
||||
return KHeavyHashHashRate(
|
||||
rate=self.rate - other.into(self.unit).rate, unit=self.unit
|
||||
)
|
||||
return KHeavyHashHashRate(rate=self.rate - other, unit=self.unit)
|
||||
|
||||
def __truediv__(self, other: KHeavyHashHashRate | int | float):
|
||||
if isinstance(other, KHeavyHashHashRate):
|
||||
return KHeavyHashHashRate(
|
||||
rate=self.rate / other.into(self.unit).rate, unit=self.unit
|
||||
)
|
||||
return KHeavyHashHashRate(rate=self.rate / other, unit=self.unit)
|
||||
|
||||
def __floordiv__(self, other: KHeavyHashHashRate | int | float):
|
||||
if isinstance(other, KHeavyHashHashRate):
|
||||
return KHeavyHashHashRate(
|
||||
rate=self.rate // other.into(self.unit).rate, unit=self.unit
|
||||
)
|
||||
return KHeavyHashHashRate(rate=self.rate // other, unit=self.unit)
|
||||
|
||||
def __mul__(self, other: KHeavyHashHashRate | int | float):
|
||||
if isinstance(other, KHeavyHashHashRate):
|
||||
return KHeavyHashHashRate(
|
||||
rate=self.rate * other.into(self.unit).rate, unit=self.unit
|
||||
)
|
||||
return KHeavyHashHashRate(rate=self.rate * other, unit=self.unit)
|
||||
|
||||
def into(self, other: KHeavyHashUnit) -> KHeavyHashHashRate:
|
||||
return KHeavyHashHashRate(
|
||||
def into(self, other: KHeavyHashUnit) -> Self:
|
||||
return self.__class__(
|
||||
rate=self.rate / (other.value / self.unit.value), unit=other
|
||||
)
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing_extensions import Self
|
||||
|
||||
from pyasic.device.algorithm.hashrate.base import AlgoHashRateType
|
||||
from pyasic.device.algorithm.hashrate.unit.scrypt import ScryptUnit
|
||||
|
||||
@@ -10,42 +12,7 @@ class ScryptHashRate(AlgoHashRateType):
|
||||
rate: float
|
||||
unit: ScryptUnit = HashUnit.SCRYPT.default
|
||||
|
||||
def __add__(self, other: ScryptHashRate | int | float) -> ScryptHashRate:
|
||||
if isinstance(other, ScryptHashRate):
|
||||
return ScryptHashRate(
|
||||
rate=self.rate + other.into(self.unit).rate, unit=self.unit
|
||||
)
|
||||
return ScryptHashRate(rate=self.rate + other, unit=self.unit)
|
||||
|
||||
def __sub__(self, other: ScryptHashRate | int | float) -> ScryptHashRate:
|
||||
if isinstance(other, ScryptHashRate):
|
||||
return ScryptHashRate(
|
||||
rate=self.rate - other.into(self.unit).rate, unit=self.unit
|
||||
)
|
||||
return ScryptHashRate(rate=self.rate - other, unit=self.unit)
|
||||
|
||||
def __truediv__(self, other: ScryptHashRate | int | float):
|
||||
if isinstance(other, ScryptHashRate):
|
||||
return ScryptHashRate(
|
||||
rate=self.rate / other.into(self.unit).rate, unit=self.unit
|
||||
)
|
||||
return ScryptHashRate(rate=self.rate / other, unit=self.unit)
|
||||
|
||||
def __floordiv__(self, other: ScryptHashRate | int | float):
|
||||
if isinstance(other, ScryptHashRate):
|
||||
return ScryptHashRate(
|
||||
rate=self.rate // other.into(self.unit).rate, unit=self.unit
|
||||
)
|
||||
return ScryptHashRate(rate=self.rate // other, unit=self.unit)
|
||||
|
||||
def __mul__(self, other: ScryptHashRate | int | float):
|
||||
if isinstance(other, ScryptHashRate):
|
||||
return ScryptHashRate(
|
||||
rate=self.rate * other.into(self.unit).rate, unit=self.unit
|
||||
)
|
||||
return ScryptHashRate(rate=self.rate * other, unit=self.unit)
|
||||
|
||||
def into(self, other: ScryptUnit) -> ScryptHashRate:
|
||||
return ScryptHashRate(
|
||||
def into(self, other: ScryptUnit) -> Self:
|
||||
return self.__class__(
|
||||
rate=self.rate / (other.value / self.unit.value), unit=other
|
||||
)
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing_extensions import Self
|
||||
|
||||
from pyasic.device.algorithm.hashrate.base import AlgoHashRateType
|
||||
from pyasic.device.algorithm.hashrate.unit.sha256 import SHA256Unit
|
||||
|
||||
@@ -10,42 +12,7 @@ class SHA256HashRate(AlgoHashRateType):
|
||||
rate: float
|
||||
unit: SHA256Unit = HashUnit.SHA256.default
|
||||
|
||||
def __add__(self, other: SHA256HashRate | int | float) -> SHA256HashRate:
|
||||
if isinstance(other, SHA256HashRate):
|
||||
return SHA256HashRate(
|
||||
rate=self.rate + other.into(self.unit).rate, unit=self.unit
|
||||
)
|
||||
return SHA256HashRate(rate=self.rate + other, unit=self.unit)
|
||||
|
||||
def __sub__(self, other: SHA256HashRate | int | float) -> SHA256HashRate:
|
||||
if isinstance(other, SHA256HashRate):
|
||||
return SHA256HashRate(
|
||||
rate=self.rate - other.into(self.unit).rate, unit=self.unit
|
||||
)
|
||||
return SHA256HashRate(rate=self.rate - other, unit=self.unit)
|
||||
|
||||
def __truediv__(self, other: SHA256HashRate | int | float):
|
||||
if isinstance(other, SHA256HashRate):
|
||||
return SHA256HashRate(
|
||||
rate=self.rate / other.into(self.unit).rate, unit=self.unit
|
||||
)
|
||||
return SHA256HashRate(rate=self.rate / other, unit=self.unit)
|
||||
|
||||
def __floordiv__(self, other: SHA256HashRate | int | float):
|
||||
if isinstance(other, SHA256HashRate):
|
||||
return SHA256HashRate(
|
||||
rate=self.rate // other.into(self.unit).rate, unit=self.unit
|
||||
)
|
||||
return SHA256HashRate(rate=self.rate // other, unit=self.unit)
|
||||
|
||||
def __mul__(self, other: SHA256HashRate | int | float):
|
||||
if isinstance(other, SHA256HashRate):
|
||||
return SHA256HashRate(
|
||||
rate=self.rate * other.into(self.unit).rate, unit=self.unit
|
||||
)
|
||||
return SHA256HashRate(rate=self.rate * other, unit=self.unit)
|
||||
|
||||
def into(self, other: SHA256Unit) -> SHA256HashRate:
|
||||
return SHA256HashRate(
|
||||
def into(self, other: SHA256Unit) -> Self:
|
||||
return self.__class__(
|
||||
rate=self.rate / (other.value / self.unit.value), unit=other
|
||||
)
|
||||
|
||||
@@ -10,8 +10,46 @@ class AlgoHashRateUnitType(IntEnum):
|
||||
PH: int
|
||||
EH: int
|
||||
ZH: int
|
||||
|
||||
default: int
|
||||
|
||||
def __str__(self):
|
||||
if self.value == self.H:
|
||||
return "H/s"
|
||||
if self.value == self.KH:
|
||||
return "KH/s"
|
||||
if self.value == self.MH:
|
||||
return "MH/s"
|
||||
if self.value == self.GH:
|
||||
return "GH/s"
|
||||
if self.value == self.TH:
|
||||
return "TH/s"
|
||||
if self.value == self.PH:
|
||||
return "PH/s"
|
||||
if self.value == self.EH:
|
||||
return "EH/s"
|
||||
if self.value == self.ZH:
|
||||
return "ZH/s"
|
||||
|
||||
@classmethod
|
||||
def from_str(cls, value):
|
||||
def from_str(cls, value: str):
|
||||
if value == "H":
|
||||
return cls.H
|
||||
elif value == "KH":
|
||||
return cls.KH
|
||||
elif value == "MH":
|
||||
return cls.MH
|
||||
elif value == "GH":
|
||||
return cls.GH
|
||||
elif value == "TH":
|
||||
return cls.TH
|
||||
elif value == "PH":
|
||||
return cls.PH
|
||||
elif value == "EH":
|
||||
return cls.EH
|
||||
elif value == "ZH":
|
||||
return cls.ZH
|
||||
return cls.default
|
||||
|
||||
def __repr__(self):
|
||||
return str(self)
|
||||
|
||||
@@ -14,44 +14,3 @@ class Blake256Unit(AlgoHashRateUnitType):
|
||||
ZH = int(EH) * 1000
|
||||
|
||||
default = TH
|
||||
|
||||
def __str__(self):
|
||||
if self.value == self.H:
|
||||
return "H/s"
|
||||
if self.value == self.KH:
|
||||
return "KH/s"
|
||||
if self.value == self.MH:
|
||||
return "MH/s"
|
||||
if self.value == self.GH:
|
||||
return "GH/s"
|
||||
if self.value == self.TH:
|
||||
return "TH/s"
|
||||
if self.value == self.PH:
|
||||
return "PH/s"
|
||||
if self.value == self.EH:
|
||||
return "EH/s"
|
||||
if self.value == self.ZH:
|
||||
return "ZH/s"
|
||||
|
||||
@classmethod
|
||||
def from_str(cls, value: str):
|
||||
if value == "H":
|
||||
return cls.H
|
||||
elif value == "KH":
|
||||
return cls.KH
|
||||
elif value == "MH":
|
||||
return cls.MH
|
||||
elif value == "GH":
|
||||
return cls.GH
|
||||
elif value == "TH":
|
||||
return cls.TH
|
||||
elif value == "PH":
|
||||
return cls.PH
|
||||
elif value == "EH":
|
||||
return cls.EH
|
||||
elif value == "ZH":
|
||||
return cls.ZH
|
||||
return cls.default
|
||||
|
||||
def __repr__(self):
|
||||
return str(self)
|
||||
|
||||
@@ -14,44 +14,3 @@ class EaglesongUnit(AlgoHashRateUnitType):
|
||||
ZH = int(EH) * 1000
|
||||
|
||||
default = TH
|
||||
|
||||
def __str__(self):
|
||||
if self.value == self.H:
|
||||
return "H/s"
|
||||
if self.value == self.KH:
|
||||
return "KH/s"
|
||||
if self.value == self.MH:
|
||||
return "MH/s"
|
||||
if self.value == self.GH:
|
||||
return "GH/s"
|
||||
if self.value == self.TH:
|
||||
return "TH/s"
|
||||
if self.value == self.PH:
|
||||
return "PH/s"
|
||||
if self.value == self.EH:
|
||||
return "EH/s"
|
||||
if self.value == self.ZH:
|
||||
return "ZH/s"
|
||||
|
||||
@classmethod
|
||||
def from_str(cls, value: str):
|
||||
if value == "H":
|
||||
return cls.H
|
||||
elif value == "KH":
|
||||
return cls.KH
|
||||
elif value == "MH":
|
||||
return cls.MH
|
||||
elif value == "GH":
|
||||
return cls.GH
|
||||
elif value == "TH":
|
||||
return cls.TH
|
||||
elif value == "PH":
|
||||
return cls.PH
|
||||
elif value == "EH":
|
||||
return cls.EH
|
||||
elif value == "ZH":
|
||||
return cls.ZH
|
||||
return cls.default
|
||||
|
||||
def __repr__(self):
|
||||
return str(self)
|
||||
|
||||
@@ -32,26 +32,3 @@ class EquihashUnit(AlgoHashRateUnitType):
|
||||
return "ESol/s"
|
||||
if self.value == self.ZH:
|
||||
return "ZSol/s"
|
||||
|
||||
@classmethod
|
||||
def from_str(cls, value: str):
|
||||
if value == "H":
|
||||
return cls.H
|
||||
elif value == "KH":
|
||||
return cls.KH
|
||||
elif value == "MH":
|
||||
return cls.MH
|
||||
elif value == "GH":
|
||||
return cls.GH
|
||||
elif value == "TH":
|
||||
return cls.TH
|
||||
elif value == "PH":
|
||||
return cls.PH
|
||||
elif value == "EH":
|
||||
return cls.EH
|
||||
elif value == "ZH":
|
||||
return cls.ZH
|
||||
return cls.default
|
||||
|
||||
def __repr__(self):
|
||||
return str(self)
|
||||
|
||||
@@ -14,44 +14,3 @@ class EtHashUnit(AlgoHashRateUnitType):
|
||||
ZH = int(EH) * 1000
|
||||
|
||||
default = MH
|
||||
|
||||
def __str__(self):
|
||||
if self.value == self.H:
|
||||
return "H/s"
|
||||
if self.value == self.KH:
|
||||
return "KH/s"
|
||||
if self.value == self.MH:
|
||||
return "MH/s"
|
||||
if self.value == self.GH:
|
||||
return "GH/s"
|
||||
if self.value == self.TH:
|
||||
return "TH/s"
|
||||
if self.value == self.PH:
|
||||
return "PH/s"
|
||||
if self.value == self.EH:
|
||||
return "EH/s"
|
||||
if self.value == self.ZH:
|
||||
return "ZH/s"
|
||||
|
||||
@classmethod
|
||||
def from_str(cls, value: str):
|
||||
if value == "H":
|
||||
return cls.H
|
||||
elif value == "KH":
|
||||
return cls.KH
|
||||
elif value == "MH":
|
||||
return cls.MH
|
||||
elif value == "GH":
|
||||
return cls.GH
|
||||
elif value == "TH":
|
||||
return cls.TH
|
||||
elif value == "PH":
|
||||
return cls.PH
|
||||
elif value == "EH":
|
||||
return cls.EH
|
||||
elif value == "ZH":
|
||||
return cls.ZH
|
||||
return cls.default
|
||||
|
||||
def __repr__(self):
|
||||
return str(self)
|
||||
|
||||
@@ -14,44 +14,3 @@ class HandshakeUnit(AlgoHashRateUnitType):
|
||||
ZH = int(EH) * 1000
|
||||
|
||||
default = TH
|
||||
|
||||
def __str__(self):
|
||||
if self.value == self.H:
|
||||
return "H/s"
|
||||
if self.value == self.KH:
|
||||
return "KH/s"
|
||||
if self.value == self.MH:
|
||||
return "MH/s"
|
||||
if self.value == self.GH:
|
||||
return "GH/s"
|
||||
if self.value == self.TH:
|
||||
return "TH/s"
|
||||
if self.value == self.PH:
|
||||
return "PH/s"
|
||||
if self.value == self.EH:
|
||||
return "EH/s"
|
||||
if self.value == self.ZH:
|
||||
return "ZH/s"
|
||||
|
||||
@classmethod
|
||||
def from_str(cls, value: str):
|
||||
if value == "H":
|
||||
return cls.H
|
||||
elif value == "KH":
|
||||
return cls.KH
|
||||
elif value == "MH":
|
||||
return cls.MH
|
||||
elif value == "GH":
|
||||
return cls.GH
|
||||
elif value == "TH":
|
||||
return cls.TH
|
||||
elif value == "PH":
|
||||
return cls.PH
|
||||
elif value == "EH":
|
||||
return cls.EH
|
||||
elif value == "ZH":
|
||||
return cls.ZH
|
||||
return cls.default
|
||||
|
||||
def __repr__(self):
|
||||
return str(self)
|
||||
|
||||
@@ -14,44 +14,3 @@ class KadenaUnit(AlgoHashRateUnitType):
|
||||
ZH = int(EH) * 1000
|
||||
|
||||
default = TH
|
||||
|
||||
def __str__(self):
|
||||
if self.value == self.H:
|
||||
return "H/s"
|
||||
if self.value == self.KH:
|
||||
return "KH/s"
|
||||
if self.value == self.MH:
|
||||
return "MH/s"
|
||||
if self.value == self.GH:
|
||||
return "GH/s"
|
||||
if self.value == self.TH:
|
||||
return "TH/s"
|
||||
if self.value == self.PH:
|
||||
return "PH/s"
|
||||
if self.value == self.EH:
|
||||
return "EH/s"
|
||||
if self.value == self.ZH:
|
||||
return "ZH/s"
|
||||
|
||||
@classmethod
|
||||
def from_str(cls, value: str):
|
||||
if value == "H":
|
||||
return cls.H
|
||||
elif value == "KH":
|
||||
return cls.KH
|
||||
elif value == "MH":
|
||||
return cls.MH
|
||||
elif value == "GH":
|
||||
return cls.GH
|
||||
elif value == "TH":
|
||||
return cls.TH
|
||||
elif value == "PH":
|
||||
return cls.PH
|
||||
elif value == "EH":
|
||||
return cls.EH
|
||||
elif value == "ZH":
|
||||
return cls.ZH
|
||||
return cls.default
|
||||
|
||||
def __repr__(self):
|
||||
return str(self)
|
||||
|
||||
@@ -14,44 +14,3 @@ class KHeavyHashUnit(AlgoHashRateUnitType):
|
||||
ZH = int(EH) * 1000
|
||||
|
||||
default = TH
|
||||
|
||||
def __str__(self):
|
||||
if self.value == self.H:
|
||||
return "H/s"
|
||||
if self.value == self.KH:
|
||||
return "KH/s"
|
||||
if self.value == self.MH:
|
||||
return "MH/s"
|
||||
if self.value == self.GH:
|
||||
return "GH/s"
|
||||
if self.value == self.TH:
|
||||
return "TH/s"
|
||||
if self.value == self.PH:
|
||||
return "PH/s"
|
||||
if self.value == self.EH:
|
||||
return "EH/s"
|
||||
if self.value == self.ZH:
|
||||
return "ZH/s"
|
||||
|
||||
@classmethod
|
||||
def from_str(cls, value: str):
|
||||
if value == "H":
|
||||
return cls.H
|
||||
elif value == "KH":
|
||||
return cls.KH
|
||||
elif value == "MH":
|
||||
return cls.MH
|
||||
elif value == "GH":
|
||||
return cls.GH
|
||||
elif value == "TH":
|
||||
return cls.TH
|
||||
elif value == "PH":
|
||||
return cls.PH
|
||||
elif value == "EH":
|
||||
return cls.EH
|
||||
elif value == "ZH":
|
||||
return cls.ZH
|
||||
return cls.default
|
||||
|
||||
def __repr__(self):
|
||||
return str(self)
|
||||
|
||||
@@ -14,44 +14,3 @@ class ScryptUnit(IntEnum):
|
||||
ZH = int(EH) * 1000
|
||||
|
||||
default = GH
|
||||
|
||||
def __str__(self):
|
||||
if self.value == self.H:
|
||||
return "H/s"
|
||||
if self.value == self.KH:
|
||||
return "KH/s"
|
||||
if self.value == self.MH:
|
||||
return "MH/s"
|
||||
if self.value == self.GH:
|
||||
return "GH/s"
|
||||
if self.value == self.TH:
|
||||
return "TH/s"
|
||||
if self.value == self.PH:
|
||||
return "PH/s"
|
||||
if self.value == self.EH:
|
||||
return "EH/s"
|
||||
if self.value == self.ZH:
|
||||
return "ZH/s"
|
||||
|
||||
@classmethod
|
||||
def from_str(cls, value: str):
|
||||
if value == "H":
|
||||
return cls.H
|
||||
elif value == "KH":
|
||||
return cls.KH
|
||||
elif value == "MH":
|
||||
return cls.MH
|
||||
elif value == "GH":
|
||||
return cls.GH
|
||||
elif value == "TH":
|
||||
return cls.TH
|
||||
elif value == "PH":
|
||||
return cls.PH
|
||||
elif value == "EH":
|
||||
return cls.EH
|
||||
elif value == "ZH":
|
||||
return cls.ZH
|
||||
return cls.default
|
||||
|
||||
def __repr__(self):
|
||||
return str(self)
|
||||
|
||||
@@ -14,44 +14,3 @@ class SHA256Unit(AlgoHashRateUnitType):
|
||||
ZH = int(EH) * 1000
|
||||
|
||||
default = TH
|
||||
|
||||
def __str__(self):
|
||||
if self.value == self.H:
|
||||
return "H/s"
|
||||
if self.value == self.KH:
|
||||
return "KH/s"
|
||||
if self.value == self.MH:
|
||||
return "MH/s"
|
||||
if self.value == self.GH:
|
||||
return "GH/s"
|
||||
if self.value == self.TH:
|
||||
return "TH/s"
|
||||
if self.value == self.PH:
|
||||
return "PH/s"
|
||||
if self.value == self.EH:
|
||||
return "EH/s"
|
||||
if self.value == self.ZH:
|
||||
return "ZH/s"
|
||||
|
||||
@classmethod
|
||||
def from_str(cls, value: str):
|
||||
if value == "H":
|
||||
return cls.H
|
||||
elif value == "KH":
|
||||
return cls.KH
|
||||
elif value == "MH":
|
||||
return cls.MH
|
||||
elif value == "GH":
|
||||
return cls.GH
|
||||
elif value == "TH":
|
||||
return cls.TH
|
||||
elif value == "PH":
|
||||
return cls.PH
|
||||
elif value == "EH":
|
||||
return cls.EH
|
||||
elif value == "ZH":
|
||||
return cls.ZH
|
||||
return cls.default
|
||||
|
||||
def __repr__(self):
|
||||
return str(self)
|
||||
|
||||
@@ -14,44 +14,3 @@ class X11Unit(AlgoHashRateUnitType):
|
||||
ZH = int(EH) * 1000
|
||||
|
||||
default = GH
|
||||
|
||||
def __str__(self):
|
||||
if self.value == self.H:
|
||||
return "H/s"
|
||||
if self.value == self.KH:
|
||||
return "KH/s"
|
||||
if self.value == self.MH:
|
||||
return "MH/s"
|
||||
if self.value == self.GH:
|
||||
return "GH/s"
|
||||
if self.value == self.TH:
|
||||
return "TH/s"
|
||||
if self.value == self.PH:
|
||||
return "PH/s"
|
||||
if self.value == self.EH:
|
||||
return "EH/s"
|
||||
if self.value == self.ZH:
|
||||
return "ZH/s"
|
||||
|
||||
@classmethod
|
||||
def from_str(cls, value: str):
|
||||
if value == "H":
|
||||
return cls.H
|
||||
elif value == "KH":
|
||||
return cls.KH
|
||||
elif value == "MH":
|
||||
return cls.MH
|
||||
elif value == "GH":
|
||||
return cls.GH
|
||||
elif value == "TH":
|
||||
return cls.TH
|
||||
elif value == "PH":
|
||||
return cls.PH
|
||||
elif value == "EH":
|
||||
return cls.EH
|
||||
elif value == "ZH":
|
||||
return cls.ZH
|
||||
return cls.default
|
||||
|
||||
def __repr__(self):
|
||||
return str(self)
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing_extensions import Self
|
||||
|
||||
from pyasic.device.algorithm.hashrate.base import AlgoHashRateType
|
||||
from pyasic.device.algorithm.hashrate.unit.x11 import X11Unit
|
||||
|
||||
@@ -10,40 +12,7 @@ class X11HashRate(AlgoHashRateType):
|
||||
rate: float
|
||||
unit: X11Unit = HashUnit.X11.default
|
||||
|
||||
def __add__(self, other: X11HashRate | int | float) -> X11HashRate:
|
||||
if isinstance(other, X11HashRate):
|
||||
return X11HashRate(
|
||||
rate=self.rate + other.into(self.unit).rate, unit=self.unit
|
||||
)
|
||||
return X11HashRate(rate=self.rate + other, unit=self.unit)
|
||||
|
||||
def __sub__(self, other: X11HashRate | int | float) -> X11HashRate:
|
||||
if isinstance(other, X11HashRate):
|
||||
return X11HashRate(
|
||||
rate=self.rate - other.into(self.unit).rate, unit=self.unit
|
||||
)
|
||||
return X11HashRate(rate=self.rate - other, unit=self.unit)
|
||||
|
||||
def __truediv__(self, other: X11HashRate | int | float):
|
||||
if isinstance(other, X11HashRate):
|
||||
return X11HashRate(
|
||||
rate=self.rate / other.into(self.unit).rate, unit=self.unit
|
||||
)
|
||||
return X11HashRate(rate=self.rate / other, unit=self.unit)
|
||||
|
||||
def __floordiv__(self, other: X11HashRate | int | float):
|
||||
if isinstance(other, X11HashRate):
|
||||
return X11HashRate(
|
||||
rate=self.rate // other.into(self.unit).rate, unit=self.unit
|
||||
)
|
||||
return X11HashRate(rate=self.rate // other, unit=self.unit)
|
||||
|
||||
def __mul__(self, other: X11HashRate | int | float):
|
||||
if isinstance(other, X11HashRate):
|
||||
return X11HashRate(
|
||||
rate=self.rate * other.into(self.unit).rate, unit=self.unit
|
||||
)
|
||||
return X11HashRate(rate=self.rate * other, unit=self.unit)
|
||||
|
||||
def into(self, other: X11Unit) -> X11HashRate:
|
||||
return X11HashRate(rate=self.rate / (other.value / self.unit.value), unit=other)
|
||||
def into(self, other: X11Unit) -> Self:
|
||||
return self.__class__(
|
||||
rate=self.rate / (other.value / self.unit.value), unit=other
|
||||
)
|
||||
|
||||
@@ -6,12 +6,8 @@ from .hashrate.unit import KadenaUnit
|
||||
|
||||
|
||||
# make this json serializable
|
||||
class _KadenaAlgo(MinerAlgoType):
|
||||
hashrate = KadenaHashRate
|
||||
unit = KadenaUnit
|
||||
class KadenaAlgo(MinerAlgoType):
|
||||
hashrate: type[KadenaHashRate] = KadenaHashRate
|
||||
unit: type[KadenaUnit] = KadenaUnit
|
||||
|
||||
def __repr__(self):
|
||||
return "KadenaAlgo"
|
||||
|
||||
|
||||
KadenaAlgo = _KadenaAlgo("Kadena")
|
||||
name = "Kadena"
|
||||
|
||||
@@ -6,12 +6,8 @@ from .hashrate.unit import KHeavyHashUnit
|
||||
|
||||
|
||||
# make this json serializable
|
||||
class _KHeavyHashAlgo(MinerAlgoType):
|
||||
hashrate = KHeavyHashHashRate
|
||||
unit = KHeavyHashUnit
|
||||
class KHeavyHashAlgo(MinerAlgoType):
|
||||
hashrate: type[KHeavyHashHashRate] = KHeavyHashHashRate
|
||||
unit: type[KHeavyHashUnit] = KHeavyHashUnit
|
||||
|
||||
def __repr__(self):
|
||||
return "KHeavyHashAlgo"
|
||||
|
||||
|
||||
KHeavyHashAlgo = _KHeavyHashAlgo("KHeavyHash")
|
||||
name = "KHeavyHash"
|
||||
|
||||
@@ -5,13 +5,8 @@ from .hashrate import ScryptHashRate
|
||||
from .hashrate.unit import ScryptUnit
|
||||
|
||||
|
||||
# make this json serializable
|
||||
class _ScryptAlgo(MinerAlgoType):
|
||||
hashrate = ScryptHashRate
|
||||
unit = ScryptUnit
|
||||
class ScryptAlgo(MinerAlgoType):
|
||||
hashrate: type[ScryptHashRate] = ScryptHashRate
|
||||
unit: type[ScryptUnit] = ScryptUnit
|
||||
|
||||
def __repr__(self):
|
||||
return "ScryptAlgo"
|
||||
|
||||
|
||||
ScryptAlgo = _ScryptAlgo("Scrypt")
|
||||
name = "Scrypt"
|
||||
|
||||
@@ -6,12 +6,8 @@ from .hashrate.unit import SHA256Unit
|
||||
|
||||
|
||||
# make this json serializable
|
||||
class _SHA256Algo(MinerAlgoType):
|
||||
hashrate = SHA256HashRate
|
||||
unit = SHA256Unit
|
||||
class SHA256Algo(MinerAlgoType):
|
||||
hashrate: type[SHA256HashRate] = SHA256HashRate
|
||||
unit: type[SHA256Unit] = SHA256Unit
|
||||
|
||||
def __repr__(self):
|
||||
return "SHA256Algo"
|
||||
|
||||
|
||||
SHA256Algo = _SHA256Algo("SHA256")
|
||||
name = "SHA256"
|
||||
|
||||
@@ -6,12 +6,8 @@ from .hashrate.unit import X11Unit
|
||||
|
||||
|
||||
# make this json serializable
|
||||
class _X11Algo(MinerAlgoType):
|
||||
hashrate = X11HashRate
|
||||
unit = X11Unit
|
||||
class X11Algo(MinerAlgoType):
|
||||
hashrate: type[X11HashRate] = X11HashRate
|
||||
unit: type[X11Unit] = X11Unit
|
||||
|
||||
def __repr__(self):
|
||||
return "X11Algo"
|
||||
|
||||
|
||||
X11Algo = _X11Algo("X11")
|
||||
name = "X11"
|
||||
|
||||
99
pyasic/miners/antminer/hiveon/X19/S19.py
Normal file
99
pyasic/miners/antminer/hiveon/X19/S19.py
Normal file
@@ -0,0 +1,99 @@
|
||||
# ------------------------------------------------------------------------------
|
||||
# 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 Hiveon
|
||||
from pyasic.miners.device.models import (
|
||||
S19,
|
||||
S19L,
|
||||
S19XP,
|
||||
S19a,
|
||||
S19aPro,
|
||||
S19Hydro,
|
||||
S19i,
|
||||
S19j,
|
||||
S19jNoPIC,
|
||||
S19jPro,
|
||||
S19KPro,
|
||||
S19Plus,
|
||||
S19Pro,
|
||||
S19ProHydro,
|
||||
S19ProPlus,
|
||||
S19ProPlusHydro,
|
||||
)
|
||||
|
||||
|
||||
class HiveonS19(Hiveon, S19):
|
||||
pass
|
||||
|
||||
|
||||
class HiveonS19Plus(Hiveon, S19Plus):
|
||||
pass
|
||||
|
||||
|
||||
class HiveonS19i(Hiveon, S19i):
|
||||
pass
|
||||
|
||||
|
||||
class HiveonS19Pro(Hiveon, S19Pro):
|
||||
pass
|
||||
|
||||
|
||||
class HiveonS19ProPlus(Hiveon, S19ProPlus):
|
||||
pass
|
||||
|
||||
|
||||
class HiveonS19XP(Hiveon, S19XP):
|
||||
pass
|
||||
|
||||
|
||||
class HiveonS19a(Hiveon, S19a):
|
||||
pass
|
||||
|
||||
|
||||
class HiveonS19aPro(Hiveon, S19aPro):
|
||||
pass
|
||||
|
||||
|
||||
class HiveonS19j(Hiveon, S19j):
|
||||
pass
|
||||
|
||||
|
||||
class HiveonS19jNoPIC(Hiveon, S19jNoPIC):
|
||||
pass
|
||||
|
||||
|
||||
class HiveonS19jPro(Hiveon, S19jPro):
|
||||
pass
|
||||
|
||||
|
||||
class HiveonS19L(Hiveon, S19L):
|
||||
pass
|
||||
|
||||
|
||||
class HiveonS19ProHydro(Hiveon, S19ProHydro):
|
||||
pass
|
||||
|
||||
|
||||
class HiveonS19Hydro(Hiveon, S19Hydro):
|
||||
pass
|
||||
|
||||
|
||||
class HiveonS19ProPlusHydro(Hiveon, S19ProPlusHydro):
|
||||
pass
|
||||
|
||||
|
||||
class HiveonS19KPro(Hiveon, S19KPro):
|
||||
pass
|
||||
22
pyasic/miners/antminer/hiveon/X19/T19.py
Normal file
22
pyasic/miners/antminer/hiveon/X19/T19.py
Normal file
@@ -0,0 +1,22 @@
|
||||
# ------------------------------------------------------------------------------
|
||||
# Copyright 2022 Upstream Data Inc -
|
||||
# -
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); -
|
||||
# you may not use this file except in compliance with the License. -
|
||||
# You may obtain a copy of the License at -
|
||||
# -
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 -
|
||||
# -
|
||||
# Unless required by applicable law or agreed to in writing, software -
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, -
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -
|
||||
# See the License for the specific language governing permissions and -
|
||||
# limitations under the License. -
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
from pyasic.miners.backends import Hiveon
|
||||
from pyasic.miners.device.models import T19
|
||||
|
||||
|
||||
class HiveonT19(Hiveon, T19):
|
||||
pass
|
||||
35
pyasic/miners/antminer/hiveon/X19/__init__.py
Normal file
35
pyasic/miners/antminer/hiveon/X19/__init__.py
Normal file
@@ -0,0 +1,35 @@
|
||||
# ------------------------------------------------------------------------------
|
||||
# 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 .S19 import (
|
||||
HiveonS19,
|
||||
HiveonS19a,
|
||||
HiveonS19aPro,
|
||||
HiveonS19Hydro,
|
||||
HiveonS19i,
|
||||
HiveonS19j,
|
||||
HiveonS19jNoPIC,
|
||||
HiveonS19jPro,
|
||||
HiveonS19KPro,
|
||||
HiveonS19L,
|
||||
HiveonS19Plus,
|
||||
HiveonS19Pro,
|
||||
HiveonS19ProHydro,
|
||||
HiveonS19ProPlus,
|
||||
HiveonS19ProPlusHydro,
|
||||
HiveonS19XP,
|
||||
)
|
||||
from .T19 import HiveonT19
|
||||
@@ -78,17 +78,6 @@ class HiveonT9(Hiveon, T9):
|
||||
### DATA GATHERING FUNCTIONS (get_{some_data}) ###
|
||||
##################################################
|
||||
|
||||
async def get_mac(self):
|
||||
try:
|
||||
mac = (
|
||||
(await self.send_ssh_command("cat /sys/class/net/eth0/address"))
|
||||
.strip()
|
||||
.upper()
|
||||
)
|
||||
return mac
|
||||
except (TypeError, ValueError, asyncssh.Error, OSError, AttributeError):
|
||||
pass
|
||||
|
||||
async def _get_hashboards(self, rpc_stats: dict = None) -> List[HashBoard]:
|
||||
hashboards = [
|
||||
HashBoard(slot=board, expected_chips=self.expected_chips)
|
||||
@@ -133,23 +122,6 @@ class HiveonT9(Hiveon, T9):
|
||||
|
||||
return hashboards
|
||||
|
||||
async def _get_wattage(self, rpc_stats: dict = None) -> Optional[int]:
|
||||
if not rpc_stats:
|
||||
try:
|
||||
rpc_stats = await self.rpc.stats()
|
||||
except APIError:
|
||||
pass
|
||||
|
||||
if rpc_stats:
|
||||
boards = rpc_stats.get("STATS")
|
||||
try:
|
||||
wattage_raw = boards[1]["chain_power"]
|
||||
except (KeyError, IndexError):
|
||||
pass
|
||||
else:
|
||||
# parse wattage position out of raw data
|
||||
return round(float(wattage_raw.split(" ")[0]))
|
||||
|
||||
async def _get_env_temp(self, rpc_stats: dict = None) -> Optional[float]:
|
||||
env_temp_list = []
|
||||
board_map = {
|
||||
|
||||
@@ -15,3 +15,4 @@
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
from .X9 import *
|
||||
from .X19 import *
|
||||
|
||||
@@ -598,44 +598,52 @@ class AntminerOld(CGMiner):
|
||||
pass
|
||||
|
||||
if rpc_stats is not None:
|
||||
board_offset = -1
|
||||
boards = rpc_stats["STATS"]
|
||||
if len(boards) > 1:
|
||||
for board_num in range(1, 16, 5):
|
||||
for _b_num in range(5):
|
||||
b = boards[1].get(f"chain_acn{board_num + _b_num}")
|
||||
try:
|
||||
board_offset = -1
|
||||
boards = rpc_stats["STATS"]
|
||||
if len(boards) > 1:
|
||||
for board_num in range(1, 16, 5):
|
||||
for _b_num in range(5):
|
||||
b = boards[1].get(f"chain_acn{board_num + _b_num}")
|
||||
|
||||
if b and not b == 0 and board_offset == -1:
|
||||
board_offset = board_num
|
||||
if board_offset == -1:
|
||||
board_offset = 1
|
||||
if b and not b == 0 and board_offset == -1:
|
||||
board_offset = board_num
|
||||
if board_offset == -1:
|
||||
board_offset = 1
|
||||
|
||||
for i in range(board_offset, board_offset + self.expected_hashboards):
|
||||
hashboard = HashBoard(
|
||||
slot=i - board_offset, expected_chips=self.expected_chips
|
||||
)
|
||||
for i in range(
|
||||
board_offset, board_offset + self.expected_hashboards
|
||||
):
|
||||
hashboard = HashBoard(
|
||||
slot=i - board_offset, expected_chips=self.expected_chips
|
||||
)
|
||||
|
||||
chip_temp = boards[1].get(f"temp{i}")
|
||||
if chip_temp:
|
||||
hashboard.chip_temp = round(chip_temp)
|
||||
chip_temp = boards[1].get(f"temp{i}")
|
||||
if chip_temp:
|
||||
hashboard.chip_temp = round(chip_temp)
|
||||
|
||||
temp = boards[1].get(f"temp2_{i}")
|
||||
if temp:
|
||||
hashboard.temp = round(temp)
|
||||
temp = boards[1].get(f"temp2_{i}")
|
||||
if temp:
|
||||
hashboard.temp = round(temp)
|
||||
|
||||
hashrate = boards[1].get(f"chain_rate{i}")
|
||||
if hashrate:
|
||||
hashboard.hashrate = self.algo.hashrate(
|
||||
rate=float(hashrate), unit=self.algo.unit.GH
|
||||
).into(self.algo.unit.default)
|
||||
hashrate = boards[1].get(f"chain_rate{i}")
|
||||
if hashrate:
|
||||
hashboard.hashrate = self.algo.hashrate(
|
||||
rate=float(hashrate), unit=self.algo.unit.GH
|
||||
).into(self.algo.unit.default)
|
||||
|
||||
chips = boards[1].get(f"chain_acn{i}")
|
||||
if chips:
|
||||
hashboard.chips = chips
|
||||
hashboard.missing = False
|
||||
if (not chips) or (not chips > 0):
|
||||
hashboard.missing = True
|
||||
hashboards.append(hashboard)
|
||||
chips = boards[1].get(f"chain_acn{i}")
|
||||
if chips:
|
||||
hashboard.chips = chips
|
||||
hashboard.missing = False
|
||||
if (not chips) or (not chips > 0):
|
||||
hashboard.missing = True
|
||||
hashboards.append(hashboard)
|
||||
except LookupError:
|
||||
return [
|
||||
HashBoard(slot=i, expected_chips=self.expected_chips)
|
||||
for i in range(self.expected_hashboards)
|
||||
]
|
||||
|
||||
return hashboards
|
||||
|
||||
|
||||
@@ -13,10 +13,71 @@
|
||||
# See the License for the specific language governing permissions and -
|
||||
# limitations under the License. -
|
||||
# ------------------------------------------------------------------------------
|
||||
from typing import Optional
|
||||
|
||||
from pyasic import APIError
|
||||
from pyasic.miners.backends import BMMiner
|
||||
from pyasic.miners.data import DataFunction, DataLocations, DataOptions, RPCAPICommand
|
||||
from pyasic.miners.device.firmware import HiveonFirmware
|
||||
|
||||
HIVEON_DATA_LOC = DataLocations(
|
||||
**{
|
||||
str(DataOptions.API_VERSION): DataFunction(
|
||||
"_get_api_ver",
|
||||
[RPCAPICommand("rpc_version", "version")],
|
||||
),
|
||||
str(DataOptions.FW_VERSION): DataFunction(
|
||||
"_get_fw_ver",
|
||||
[RPCAPICommand("rpc_version", "version")],
|
||||
),
|
||||
str(DataOptions.HASHRATE): DataFunction(
|
||||
"_get_hashrate",
|
||||
[RPCAPICommand("rpc_summary", "summary")],
|
||||
),
|
||||
str(DataOptions.EXPECTED_HASHRATE): DataFunction(
|
||||
"_get_expected_hashrate",
|
||||
[RPCAPICommand("rpc_stats", "stats")],
|
||||
),
|
||||
str(DataOptions.HASHBOARDS): DataFunction(
|
||||
"_get_hashboards",
|
||||
[RPCAPICommand("rpc_stats", "stats")],
|
||||
),
|
||||
str(DataOptions.WATTAGE): DataFunction(
|
||||
"_get_wattage",
|
||||
[RPCAPICommand("rpc_stats", "stats")],
|
||||
),
|
||||
str(DataOptions.FANS): DataFunction(
|
||||
"_get_fans",
|
||||
[RPCAPICommand("rpc_stats", "stats")],
|
||||
),
|
||||
str(DataOptions.UPTIME): DataFunction(
|
||||
"_get_uptime",
|
||||
[RPCAPICommand("rpc_stats", "stats")],
|
||||
),
|
||||
str(DataOptions.POOLS): DataFunction(
|
||||
"_get_pools",
|
||||
[RPCAPICommand("rpc_pools", "pools")],
|
||||
),
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
class Hiveon(BMMiner, HiveonFirmware):
|
||||
pass
|
||||
data_locations = HIVEON_DATA_LOC
|
||||
|
||||
async def _get_wattage(self, rpc_stats: dict = None) -> Optional[int]:
|
||||
if not rpc_stats:
|
||||
try:
|
||||
rpc_stats = await self.rpc.stats()
|
||||
except APIError:
|
||||
pass
|
||||
|
||||
if rpc_stats:
|
||||
boards = rpc_stats.get("STATS")
|
||||
try:
|
||||
wattage_raw = boards[1]["chain_power"]
|
||||
except (KeyError, IndexError):
|
||||
pass
|
||||
else:
|
||||
# parse wattage position out of raw data
|
||||
return round(float(wattage_raw.split(" ")[0]))
|
||||
|
||||
@@ -76,6 +76,8 @@ class LUXMiner(LuxOSFirmware):
|
||||
_rpc_cls = LUXMinerRPCAPI
|
||||
rpc: LUXMinerRPCAPI
|
||||
|
||||
supports_shutdown = True
|
||||
|
||||
data_locations = LUXMINER_DATA_LOC
|
||||
|
||||
async def fault_light_on(self) -> bool:
|
||||
|
||||
@@ -98,6 +98,11 @@ class VNish(VNishFirmware, BMMiner):
|
||||
|
||||
data_locations = VNISH_DATA_LOC
|
||||
|
||||
async def send_config(self, config: MinerConfig, user_suffix: str = None) -> None:
|
||||
await self.web.post_settings(
|
||||
miner_settings=config.as_vnish(user_suffix=user_suffix)
|
||||
)
|
||||
|
||||
async def restart_backend(self) -> bool:
|
||||
data = await self.web.restart_vnish()
|
||||
if data:
|
||||
|
||||
@@ -46,7 +46,7 @@ class MinerProtocol(Protocol):
|
||||
make: MinerMake = None
|
||||
raw_model: MinerModelType = None
|
||||
firmware: MinerFirmware = None
|
||||
algo: MinerAlgoType = None
|
||||
algo: type[MinerAlgoType] = None
|
||||
|
||||
expected_hashboards: int = None
|
||||
expected_chips: int = None
|
||||
@@ -496,7 +496,6 @@ class MinerProtocol(Protocol):
|
||||
function = getattr(self, getattr(self.data_locations, data_name).cmd)
|
||||
miner_data[data_name] = await function(**args_to_send)
|
||||
except Exception as e:
|
||||
raise e
|
||||
raise APIError(
|
||||
f"Failed to call {data_name} on {self} while getting data."
|
||||
) from e
|
||||
@@ -530,7 +529,11 @@ class MinerProtocol(Protocol):
|
||||
expected_fans=self.expected_fans,
|
||||
hashboards=[
|
||||
HashBoard(slot=i, expected_chips=self.expected_chips)
|
||||
for i in range(self.expected_hashboards)
|
||||
for i in range(
|
||||
self.expected_hashboards
|
||||
if self.expected_hashboards is not None
|
||||
else 0
|
||||
)
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
@@ -426,6 +426,7 @@ MINER_CLASSES = {
|
||||
MinerTypes.HIVEON: {
|
||||
None: Hiveon,
|
||||
"ANTMINER T9": HiveonT9,
|
||||
"ANTMINER S19JPRO": HiveonS19jPro,
|
||||
},
|
||||
MinerTypes.LUX_OS: {
|
||||
None: LUXMiner,
|
||||
@@ -630,6 +631,7 @@ class MinerFactory:
|
||||
|
||||
@staticmethod
|
||||
def _parse_web_type(web_text: str, web_resp: httpx.Response) -> MinerTypes | None:
|
||||
print(web_resp.headers)
|
||||
if web_resp.status_code == 401 and 'realm="antMiner' in web_resp.headers.get(
|
||||
"www-authenticate", ""
|
||||
):
|
||||
@@ -862,6 +864,10 @@ class MinerFactory:
|
||||
miner_model: str | None,
|
||||
miner_type: MinerTypes | None,
|
||||
) -> AnyMiner | None:
|
||||
# special case since hiveon miners return web results copying the antminer stock FW
|
||||
if "HIVEON" in str(miner_model).upper() and miner_type == MinerTypes.ANTMINER:
|
||||
miner_model = str(miner_model).upper().replace(" HIVEON", "")
|
||||
miner_type = MinerTypes.HIVEON
|
||||
try:
|
||||
return MINER_CLASSES[miner_type][str(miner_model).upper()](ip)
|
||||
except LookupError:
|
||||
|
||||
@@ -143,3 +143,6 @@ class VNishWebAPI(BaseWebAPI):
|
||||
|
||||
async def find_miner(self) -> dict:
|
||||
return await self.send_command("find-miner", privileged=True)
|
||||
|
||||
async def post_settings(self, miner_settings: dict):
|
||||
return await self.send_command("settings", post=True, **miner_settings)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[tool.poetry]
|
||||
name = "pyasic"
|
||||
version = "0.64.0"
|
||||
version = "0.64.8"
|
||||
description = "A simplified and standardized interface for Bitcoin ASICs."
|
||||
authors = ["UpstreamData <brett@upstreamdata.ca>"]
|
||||
repository = "https://github.com/UpstreamData/pyasic"
|
||||
|
||||
Reference in New Issue
Block a user