feature: add antminer new API.

This commit is contained in:
Upstream Data
2024-03-22 13:42:10 -06:00
parent 55c4e10fae
commit 1b6db7ed45
3 changed files with 45 additions and 4 deletions

View File

@@ -1,16 +1,16 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: check-yaml
- id: check-added-large-files
- repo: https://github.com/psf/black
rev: 22.6.0
rev: 24.3.0
hooks:
- id: black
- repo: https://github.com/pycqa/isort
rev: 5.10.1
rev: 5.13.2
hooks:
- id: isort
name: isort (python)

View File

@@ -22,6 +22,7 @@ from pyasic.data.error_codes import MinerErrorData, X19Error
from pyasic.errors import APIError
from pyasic.miners.backends.bmminer import BMMiner
from pyasic.miners.backends.cgminer import CGMiner
from pyasic.miners.base import BaseMiner
from pyasic.miners.data import (
DataFunction,
DataLocations,
@@ -29,6 +30,7 @@ from pyasic.miners.data import (
RPCAPICommand,
WebAPICommand,
)
from pyasic.rpc.antminer import AntminerRPCAPI
from pyasic.ssh.antminer import AntminerModernSSH
from pyasic.web.antminer import AntminerModernWebAPI, AntminerOldWebAPI
@@ -88,6 +90,9 @@ class AntminerModern(BMMiner):
_web_cls = AntminerModernWebAPI
web: AntminerModernWebAPI
_rpc_cls = AntminerRPCAPI
web: AntminerRPCAPI
_ssh_cls = AntminerModernSSH
ssh: AntminerModernSSH
@@ -207,7 +212,7 @@ class AntminerModern(BMMiner):
]
try:
rpc_stats = await self.rpc.send_command("stats", new_api=True)
rpc_stats = await self.rpc.stats(new_api=True)
except APIError:
return hashboards

36
pyasic/rpc/antminer.py Normal file
View File

@@ -0,0 +1,36 @@
from pyasic.rpc.bmminer import BMMinerRPCAPI
class AntminerRPCAPI(BMMinerRPCAPI):
async def stats(self, new_api: bool = False) -> dict:
if new_api:
return await self.send_command("stats", new_api=True)
return await super().stats()
async def rate(self):
return await self.send_command("rate", new_api=True)
async def pools(self, new_api: bool = False):
if new_api:
return await self.send_command("pools", new_api=True)
return await self.send_command("pools")
async def reload(self):
return await self.send_command("reload", new_api=True)
async def summary(self, new_api: bool = False):
if new_api:
return await self.send_command("summary", new_api=True)
return await self.send_command("summary")
async def warning(self):
return await self.send_command("warning", new_api=True)
async def new_api_pools(self):
return await self.pools(new_api=True)
async def new_api_stats(self):
return await self.stats(new_api=True)
async def new_api_summary(self):
return await self.summary(new_api=True)