* feature: handle all hashrate algorithm conversions for antminers * feature: handle all hashrate algorithm conversions for auradine * feature: handle all hashrate algorithm conversions for avalonminers * feature: handle all hashrate algorithm conversions for bitaxe * feature: handle all hashrate algorithm conversions for epic * feature: handle all hashrate algorithm conversions for goldshell * refactor: clean up imports * feature: handle all hashrate algorithm conversions for hammer * feature: handle all hashrate algorithm conversions for iceriver * feature: handle all hashrate algorithm conversions for innosilicon * feature: handle all hashrate algorithm conversions for whatsminer * tests: update tests to check if miners have board, fan, and algo values * feature: finish updating all miners with boards, fans, and algos * feature: update algorithm default values * feature: add algorithm hashrate values * feature: improve hashrate types, and use `self.algo` inside miners --------- Co-authored-by: Upstream Data <brett@upstreamdata.ca>
52 lines
2.0 KiB
Python
52 lines
2.0 KiB
Python
from __future__ import annotations
|
|
|
|
from pyasic.device.algorithm.hashrate.base import AlgoHashRateType
|
|
from pyasic.device.algorithm.hashrate.unit.equihash import EquihashUnit
|
|
|
|
from .unit import HashUnit
|
|
|
|
|
|
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(
|
|
rate=self.rate / (other.value / self.unit.value), unit=other
|
|
)
|