From 63522aad81077e3221066843ba8e8ea5426e6cd1 Mon Sep 17 00:00:00 2001 From: Upstream Data Date: Tue, 20 Aug 2024 08:37:40 -0600 Subject: [PATCH] feature: add mara rpc API. --- pyasic/miners/backends/marathon.py | 3 +++ pyasic/rpc/marathon.py | 33 ++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 pyasic/rpc/marathon.py diff --git a/pyasic/miners/backends/marathon.py b/pyasic/miners/backends/marathon.py index 0c8b1c5f..b49de89b 100644 --- a/pyasic/miners/backends/marathon.py +++ b/pyasic/miners/backends/marathon.py @@ -7,6 +7,7 @@ from pyasic.errors import APIError from pyasic.miners.data import DataFunction, DataLocations, DataOptions, WebAPICommand from pyasic.miners.device.firmware import MaraFirmware from pyasic.misc import merge_dicts +from pyasic.rpc.marathon import MaraRPCAPI from pyasic.web.marathon import MaraWebAPI MARA_DATA_LOC = DataLocations( @@ -64,6 +65,8 @@ MARA_DATA_LOC = DataLocations( class MaraMiner(MaraFirmware): + _rpc_cls = MaraRPCAPI + rpc: MaraRPCAPI _web_cls = MaraWebAPI web: MaraWebAPI diff --git a/pyasic/rpc/marathon.py b/pyasic/rpc/marathon.py new file mode 100644 index 00000000..44bb43d1 --- /dev/null +++ b/pyasic/rpc/marathon.py @@ -0,0 +1,33 @@ +from pyasic.rpc.base import BaseMinerRPCAPI + + +class MaraRPCAPI(BaseMinerRPCAPI): + """An abstraction of the MaraFW API. + + Each method corresponds to an API command in MaraFW. + + No documentation for this API is currently publicly available. + + Additionally, every command not included here just returns the result of the `summary` command. + + This class abstracts use of the MaraFW API, as well as the + methods for sending commands to it. The `self.send_command()` + function handles sending a command to the miner asynchronously, and + as such is the base for many of the functions in this class, which + rely on it to send the command for them. + """ + + async def summary(self): + return await self.send_command("summary") + + async def devs(self): + return await self.send_command("devs") + + async def pools(self): + return await self.send_command("pools") + + async def stats(self): + return await self.send_command("stats") + + async def version(self): + return await self.send_command("version")