repo
stringlengths
7
90
file_url
stringlengths
81
315
file_path
stringlengths
4
228
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 14:38:15
2026-01-05 02:33:18
truncated
bool
2 classes
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/tests/test_data.py
tests/test_data.py
# ------------------------------------------------------------------------------ # 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. - # ------------------------------------------------------------------------------ bosminer_api_pools = { "STATUS": [ { "STATUS": "S", "Msg": "2 Pool(s)", "Description": "", } ], "POOLS": [ { "POOL": 0, "URL": "stratum+tcp://pyasic.testpool_1.pool:3333", "Status": "Alive", "Quota": 1, "User": "pyasic.test", "Stratum URL": "pyasic.testpool_1.pool:3333", "AsicBoost": True, }, { "POOL": 1, "URL": "stratum+tcp://pyasic.testpool_2.pool:3333", "Status": "Alive", "Quota": 1, "User": "pyasic.test", "Stratum URL": "pyasic.testpool_2.pool:3333", "AsicBoost": True, }, ], "id": 1, } x19_api_pools = { "STATUS": [ { "STATUS": "S", "Msg": "2 Pool(s)", "Description": "", } ], "POOLS": [ { "POOL": 0, "URL": "stratum+tcp://pyasic.testpool_1.pool:3333", "Status": "Alive", "Quota": 1, "User": "pyasic.test", "Stratum URL": "pyasic.testpool_1.pool:3333", }, { "POOL": 1, "URL": "stratum+tcp://pyasic.testpool_2.pool:3333", "Status": "Alive", "Quota": 1, "User": "pyasic.test", "Stratum URL": "pyasic.testpool_2.pool:3333", }, ], "id": 1, } x19_web_pools = { "pools": [ { "url": "stratum+tcp://pyasic.testpool_1.pool:3333", "user": "pyasic.test", "pass": "123", }, { "url": "stratum+tcp://pyasic.testpool_2.pool:3333", "user": "pyasic.test", "pass": "123", }, ], "api-listen": True, "api-network": True, "api-groups": "A:stats:pools:devs:summary:version", "api-allow": "A:0/0,W:*", "bitmain-fan-ctrl": False, "bitmain-fan-pwm": "100", "bitmain-use-vil": True, "bitmain-freq": "675", "bitmain-voltage": "1400", "bitmain-ccdelay": "0", "bitmain-pwth": "0", "bitmain-work-mode": "0", "bitmain-freq-level": "100", } bosminer_config_pools = { "format": { "version": "1.2+", "model": "Antminer S9", "generator": "pyasic", }, "group": [ { "name": "TEST", "quota": 1, "pool": [ { "enabled": True, "url": "stratum+tcp://pyasic.testpool_1.pool:3333", "user": "pyasic.test", "password": "123", }, { "enabled": True, "url": "stratum+tcp://pyasic.testpool_2.pool:3333", "user": "pyasic.test", "password": "123", }, ], }, ], }
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/tests/__init__.py
tests/__init__.py
# ------------------------------------------------------------------------------ # 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 tests.config_tests import TestConfig from tests.miners_tests import * from tests.network_tests import NetworkTest from tests.rpc_tests import * if __name__ == "__main__": # `coverage run --source pyasic -m unittest discover` will give code coverage data unittest.main()
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/tests/miners_tests/__init__.py
tests/miners_tests/__init__.py
# ------------------------------------------------------------------------------ # 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. - # ------------------------------------------------------------------------------ import inspect import unittest import warnings from dataclasses import asdict from pyasic.miners.factory import MINER_CLASSES from .backends_tests import * class MinersTest(unittest.TestCase): def test_miner_type_creation(self): warnings.filterwarnings("ignore") for miner_type in MINER_CLASSES.keys(): for miner_model in MINER_CLASSES[miner_type].keys(): with self.subTest( msg="Test creation of miner", miner_type=miner_type, miner_model=miner_model, ): MINER_CLASSES[miner_type][miner_model]("127.0.0.1") def test_miner_has_hashboards(self): warnings.filterwarnings("ignore") for miner_type in MINER_CLASSES.keys(): for miner_model in MINER_CLASSES[miner_type].keys(): if miner_model is None: continue with self.subTest( msg="Test miner has defined hashboards", miner_type=miner_type, miner_model=miner_model, ): miner = MINER_CLASSES[miner_type][miner_model]("127.0.0.1") self.assertTrue(miner.expected_hashboards is not None) def test_miner_has_fans(self): warnings.filterwarnings("ignore") for miner_type in MINER_CLASSES.keys(): for miner_model in MINER_CLASSES[miner_type].keys(): if miner_model is None: continue with self.subTest( msg="Test miner has defined fans", miner_type=miner_type, miner_model=miner_model, ): miner = MINER_CLASSES[miner_type][miner_model]("127.0.0.1") self.assertTrue(miner.expected_fans is not None) def test_miner_has_algo(self): warnings.filterwarnings("ignore") for miner_type in MINER_CLASSES.keys(): for miner_model in MINER_CLASSES[miner_type].keys(): if miner_model is None: continue with self.subTest( msg="Test miner has defined algo", miner_type=miner_type, miner_model=miner_model, ): miner = MINER_CLASSES[miner_type][miner_model]("127.0.0.1") self.assertTrue(miner.algo is not None) def test_miner_data_map_keys(self): keys = sorted( [ "api_ver", "config", "env_temp", "errors", "fan_psu", "fans", "fault_light", "fw_ver", "hashboards", "hashrate", "hostname", "is_mining", "serial_number", "mac", "expected_hashrate", "uptime", "wattage", "wattage_limit", "pools", ] ) warnings.filterwarnings("ignore") for miner_type in MINER_CLASSES.keys(): for miner_model in MINER_CLASSES[miner_type].keys(): with self.subTest( msg="Data map key check", miner_type=miner_type, miner_model=miner_model, ): miner = MINER_CLASSES[miner_type][miner_model]("127.0.0.1") miner_keys = sorted( [str(k) for k in asdict(miner.data_locations).keys()] ) self.assertEqual(miner_keys, keys) def test_data_locations_match_signatures_command(self): warnings.filterwarnings("ignore") for miner_type in MINER_CLASSES.keys(): for miner_model in MINER_CLASSES[miner_type].keys(): miner = MINER_CLASSES[miner_type][miner_model]("127.0.0.1") if miner.data_locations is None: raise TypeError( f"model={miner_model} type={miner_type} has no data locations" ) for data_point in asdict(miner.data_locations).values(): with self.subTest( msg=f"Test {data_point['cmd']} signature matches", miner_type=miner_type, miner_model=miner_model, ): func = getattr(miner, data_point["cmd"]) signature = inspect.signature(func) parameters = signature.parameters param_names = list(parameters.keys()) for arg in ["kwargs", "args"]: try: param_names.remove(arg) except ValueError: pass self.assertEqual( set(param_names), set([k["name"] for k in data_point["kwargs"]]), ) if __name__ == "__main__": unittest.main()
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/tests/miners_tests/backends_tests/__init__.py
tests/miners_tests/backends_tests/__init__.py
from .avalonminer_tests import * from .elphapex_tests import * from .hammer_tests import *
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/tests/miners_tests/backends_tests/avalonminer_tests/test_web_api_json_error.py
tests/miners_tests/backends_tests/avalonminer_tests/test_web_api_json_error.py
"""Tests for AvalonMiner web API JSON error handling. This test ensures that the AvalonMiner API gracefully handles cases where endpoints return invalid JSON or HTML responses instead of the expected JSON data. Related to Issue #400: Avalon Mini 3 stopped working with v0.78.0 """ import unittest from unittest.mock import AsyncMock, MagicMock, patch import httpx from pyasic.miners.avalonminer.cgminer.mini.mini3 import CGMinerAvalonMini3 from pyasic.miners.avalonminer.cgminer.nano.nano3 import CGMinerAvalonNano3 from pyasic.web.avalonminer import AvalonMinerWebAPI class TestAvalonMinerWebAPIJsonErrors(unittest.IsolatedAsyncioTestCase): """Test AvalonMiner web API exception handling for JSON decode errors.""" async def test_send_command_json_decode_error(self): """Test that send_command handles JSON decode errors gracefully. When a CGI endpoint returns invalid JSON (e.g., HTML error page), the send_command method should return an empty dict instead of raising an exception. """ api = AvalonMinerWebAPI("192.168.1.100") with patch("pyasic.web.avalonminer.httpx.AsyncClient") as mock_client_class: mock_client = AsyncMock() mock_response = MagicMock() # Simulate invalid JSON response (e.g., HTML error page) mock_response.text = "<html><body>Error</body></html>" mock_client.get.return_value = mock_response mock_client.__aenter__.return_value = mock_client mock_client.__aexit__.return_value = None mock_client_class.return_value = mock_client result = await api.send_command("get_minerinfo") # Should return empty dict instead of raising JSONDecodeError self.assertEqual(result, {}) async def test_send_command_http_error(self): """Test that send_command handles HTTP errors gracefully. When an HTTP error occurs, send_command should return an empty dict instead of raising an exception. """ api = AvalonMinerWebAPI("192.168.1.100") with patch("pyasic.web.avalonminer.httpx.AsyncClient") as mock_client_class: mock_client = AsyncMock() mock_client.get.side_effect = httpx.HTTPError("Connection failed") mock_client.__aenter__.return_value = mock_client mock_client.__aexit__.return_value = None mock_client_class.return_value = mock_client result = await api.send_command("get_minerinfo") # Should return empty dict instead of raising HTTPError self.assertEqual(result, {}) async def test_multicommand_json_decode_error(self): """Test that multicommand handles JSON decode errors gracefully. This is the critical fix for issue #400. When a CGI endpoint returns invalid JSON (e.g., HTML error page), the multicommand method should skip that command and continue with others. """ api = AvalonMinerWebAPI("192.168.1.100") with patch("pyasic.web.avalonminer.httpx.AsyncClient") as mock_client_class: mock_client = AsyncMock() mock_client.cookies = MagicMock() async def mock_get(url): response = MagicMock() # One endpoint returns valid JSON, another returns invalid HTML if "minerinfo" in url: response.text = "<html><body>Error</body></html>" else: response.text = '{"status": "ok"}' return response mock_client.get = mock_get mock_client.__aenter__.return_value = mock_client mock_client.__aexit__.return_value = None mock_client_class.return_value = mock_client # Call multicommand with multiple endpoints result = await api.multicommand("get_minerinfo", "get_home") # Should return data from successful commands and empty dict for failed ones self.assertIn("status", result) self.assertEqual(result["status"], "ok") self.assertIn("multicommand", result) self.assertTrue(result["multicommand"]) async def test_multicommand_fallback_get_miner_info(self): """Test multicommand falls back from get_minerinfo to get_miner_info.""" api = AvalonMinerWebAPI("192.168.1.100") with patch("pyasic.web.avalonminer.httpx.AsyncClient") as mock_client_class: mock_client = AsyncMock() mock_client.cookies = MagicMock() async def mock_get(url): response = MagicMock() if "get_minerinfo" in url: response.text = "<html><body>Error</body></html>" elif "get_miner_info" in url: response.text = '{"status": "ok", "mac": "aa:bb"}' else: response.text = "{}" return response mock_client.get = mock_get mock_client.__aenter__.return_value = mock_client mock_client.__aexit__.return_value = None mock_client_class.return_value = mock_client result = await api.multicommand("get_minerinfo") self.assertIn("status", result) self.assertEqual(result["status"], "ok") self.assertTrue(result["multicommand"]) async def test_multicommand_fallback_status(self): """Test multicommand falls back from get_status to status.""" api = AvalonMinerWebAPI("192.168.1.100") with patch("pyasic.web.avalonminer.httpx.AsyncClient") as mock_client_class: mock_client = AsyncMock() mock_client.cookies = MagicMock() async def mock_get(url): response = MagicMock() if "get_status" in url: response.text = "<html><body>Error</body></html>" elif "status" in url: response.text = '{"status": "ok", "temp": 42}' else: response.text = "{}" return response mock_client.get = mock_get mock_client.__aenter__.return_value = mock_client mock_client.__aexit__.return_value = None mock_client_class.return_value = mock_client result = await api.multicommand("get_status") self.assertIn("status", result) self.assertEqual(result["status"], "ok") self.assertTrue(result["multicommand"]) async def test_minerinfo_method_fallback(self): """Test minerinfo() tries get_minerinfo then get_miner_info.""" api = AvalonMinerWebAPI("192.168.1.100") with patch.object(api, "send_command", new_callable=AsyncMock) as mock_send: mock_send.side_effect = [ {}, {"mac": "de:ad:be:ef:00:01"}, ] result = await api.minerinfo() self.assertEqual(result.get("mac"), "de:ad:be:ef:00:01") self.assertEqual(mock_send.await_count, 2) async def test_status_method_fallback(self): """Test status() tries get_status then status.""" api = AvalonMinerWebAPI("192.168.1.100") with patch.object(api, "send_command", new_callable=AsyncMock) as mock_send: mock_send.side_effect = [ {}, {"temp": 42, "status": "ok"}, ] result = await api.status() self.assertEqual(result.get("temp"), 42) self.assertEqual(mock_send.await_count, 2) async def test_multicommand_all_failures(self): """Test multicommand when all endpoints fail. When all CGI endpoints return invalid JSON, the multicommand should return a dict with only the multicommand flag set to True. """ api = AvalonMinerWebAPI("192.168.1.100") with patch("pyasic.web.avalonminer.httpx.AsyncClient") as mock_client_class: mock_client = AsyncMock() mock_client.cookies = MagicMock() async def mock_get(url): response = MagicMock() # All endpoints return invalid HTML response.text = "<html><body>404 Not Found</body></html>" return response mock_client.get = mock_get mock_client.__aenter__.return_value = mock_client mock_client.__aexit__.return_value = None mock_client_class.return_value = mock_client # Call multicommand with multiple endpoints result = await api.multicommand( "get_minerinfo", "get_home", "nonexistent_endpoint" ) # Should return a dict with only multicommand=True self.assertEqual(result, {"multicommand": True}) async def test_mini3_mac_address_fallback(self): """Test that Mini3 can fetch MAC address using get_miner_info with fallback. The Mini3 attempts to use get_miner_info first, then falls back to get_minerinfo if the first fails. This test ensures both methods work. """ miner = CGMinerAvalonMini3("192.168.1.100") with patch.object( miner.web, "miner_info", new_callable=AsyncMock ) as mock_miner_info: # Simulate successful response from get_miner_info mock_miner_info.return_value = {"mac": "00:11:22:33:44:55"} result = await miner._get_mac() self.assertEqual(result, "00:11:22:33:44:55") mock_miner_info.assert_called_once() async def test_mini3_mac_address_fallback_failure(self): """Test that Mini3 falls back from get_miner_info to get_minerinfo. When get_miner_info (with underscore) fails, the _get_mac method should fall back to get_minerinfo. This test ensures both endpoints are tried before giving up. """ from pyasic import APIError miner = CGMinerAvalonMini3("192.168.1.100") with ( patch.object( miner.web, "miner_info", new_callable=AsyncMock ) as mock_miner_info, patch.object( miner.web, "minerinfo", new_callable=AsyncMock ) as mock_minerinfo, ): # Simulate get_miner_info failing but minerinfo succeeding mock_miner_info.side_effect = APIError("Not found") mock_minerinfo.return_value = {"mac": "aa:bb:cc:dd:ee:ff"} result = await miner._get_mac() self.assertEqual(result, "AA:BB:CC:DD:EE:FF") mock_miner_info.assert_called_once() mock_minerinfo.assert_called_once() async def test_mini3_mac_address_both_fail(self): """Test that Mini3 returns None when all endpoints fail. When both get_miner_info and get_minerinfo fail, the _get_mac method should gracefully return None. """ from pyasic import APIError miner = CGMinerAvalonMini3("192.168.1.100") with ( patch.object( miner.web, "miner_info", new_callable=AsyncMock ) as mock_miner_info, patch.object( miner.web, "minerinfo", new_callable=AsyncMock ) as mock_minerinfo, ): # Simulate both endpoints failing mock_miner_info.side_effect = APIError("Not found") mock_minerinfo.side_effect = APIError("Connection failed") result = await miner._get_mac() self.assertIsNone(result) async def test_nano3_mac_address_fallback(self): """Test that Nano3 can fetch MAC address using get_miner_info with fallback. Similar to Mini3, Nano3 data locations do not include the get_minerinfo command, so fallback to get_miner_info is required. """ miner = CGMinerAvalonNano3("192.168.1.100") with patch.object( miner.web, "miner_info", new_callable=AsyncMock ) as mock_miner_info: # Simulate successful response from get_miner_info mock_miner_info.return_value = {"mac": "aa:bb:cc:dd:ee:ff"} result = await miner._get_mac() self.assertEqual(result, "AA:BB:CC:DD:EE:FF") mock_miner_info.assert_called_once() if __name__ == "__main__": unittest.main()
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/tests/miners_tests/backends_tests/avalonminer_tests/version_24102401_25462b2_9ddf522.py
tests/miners_tests/backends_tests/avalonminer_tests/version_24102401_25462b2_9ddf522.py
"""Tests for hammer miners with firmware dating 2023-05-28 17-20-35 CST""" import unittest from dataclasses import fields from unittest.mock import patch from pyasic import APIError, MinerData from pyasic.data import Fan, HashBoard from pyasic.device.algorithm import SHA256Unit from pyasic.miners.avalonminer import CGMinerAvalon1566 POOLS = [ { "url": "stratum+tcp://stratum.pool.io:3333", "user": "pool_username.real_worker", "pwd": "123", }, { "url": "stratum+tcp://stratum.pool.io:3334", "user": "pool_username.real_worker", "pwd": "123", }, { "url": "stratum+tcp://stratum.pool.io:3335", "user": "pool_username.real_worker", "pwd": "123", }, ] data = { CGMinerAvalon1566: { "rpc_version": { "STATUS": [ { "STATUS": "S", "When": 986, "Code": 22, "Msg": "CGMiner versions", "Description": "cgminer 4.11.1", } ], "VERSION": [ { "CGMiner": "4.11.1", "API": "3.7", "STM8": "20.08.01", "PROD": "AvalonMiner 15-194", "MODEL": "15-194", "HWTYPE": "MM4v2_X3", "SWTYPE": "MM319", "VERSION": "24102401_25462b2_9ddf522", "LOADER": "d0d779de.00", "DNA": "020100008c699117", "MAC": "123456789012", "UPAPI": "2", } ], "id": 1, }, "rpc_devs": { "STATUS": [ { "STATUS": "S", "When": 986, "Code": 9, "Msg": "1 ASC(s)", "Description": "cgminer 4.11.1", } ], "DEVS": [ { "ASC": 0, "Name": "AVA10", "ID": 0, "Enabled": "Y", "Status": "Alive", "Temperature": -273.0, "MHS av": 192796247.36, "MHS 30s": 197497926.49, "MHS 1m": 197266944.16, "MHS 5m": 186968586.55, "MHS 15m": 124648835.18, "Accepted": 148, "Rejected": 1, "Hardware Errors": 0, "Utility": 9.61, "Last Share Pool": 0, "Last Share Time": 975, "Total MH": 178226436366.0, "Diff1 Work": 41775104, "Difficulty Accepted": 38797312.0, "Difficulty Rejected": 262144.0, "Last Share Difficulty": 262144.0, "Last Valid Work": 986, "Device Hardware%": 0.0, "Device Rejected%": 0.6275, "Device Elapsed": 924, } ], "id": 1, }, "rpc_pools": { "STATUS": [ { "STATUS": "S", "When": 986, "Code": 7, "Msg": "3 Pool(s)", "Description": "cgminer 4.11.1", } ], "POOLS": [ { "POOL": 0, "URL": "stratum+tcp://stratum.pool.io:3333", "Status": "Alive", "Priority": 0, "Quota": 1, "Long Poll": "N", "Getworks": 27, "Accepted": 148, "Rejected": 1, "Works": 10199, "Discarded": 0, "Stale": 0, "Get Failures": 0, "Remote Failures": 0, "User": "pool_username.real_worker", "Last Share Time": 975, "Diff1 Shares": 41775104, "Proxy Type": "", "Proxy": "", "Difficulty Accepted": 38797312.0, "Difficulty Rejected": 262144.0, "Difficulty Stale": 0.0, "Last Share Difficulty": 262144.0, "Work Difficulty": 262144.0, "Has Stratum": True, "Stratum Active": True, "Stratum URL": "stratum.pool.io", "Stratum Difficulty": 262144.0, "Has Vmask": True, "Has GBT": False, "Best Share": 19649871, "Pool Rejected%": 0.6711, "Pool Stale%": 0.0, "Bad Work": 2, "Current Block Height": 882588, "Current Block Version": 536870912, }, { "POOL": 1, "URL": "stratum+tcp://stratum.pool.io:3334", "Status": "Alive", "Priority": 1, "Quota": 1, "Long Poll": "N", "Getworks": 2, "Accepted": 0, "Rejected": 0, "Works": 0, "Discarded": 0, "Stale": 0, "Get Failures": 0, "Remote Failures": 0, "User": "pool_username.real_worker", "Last Share Time": 0, "Diff1 Shares": 0, "Proxy Type": "", "Proxy": "", "Difficulty Accepted": 0.0, "Difficulty Rejected": 0.0, "Difficulty Stale": 0.0, "Last Share Difficulty": 0.0, "Work Difficulty": 0.0, "Has Stratum": True, "Stratum Active": False, "Stratum URL": "stratum.pool.io", "Stratum Difficulty": 0.0, "Has Vmask": True, "Has GBT": False, "Best Share": 0, "Pool Rejected%": 0.0, "Pool Stale%": 0.0, "Bad Work": 0, "Current Block Height": 0, "Current Block Version": 536870912, }, { "POOL": 2, "URL": "stratum+tcp://stratum.pool.io:3335", "Status": "Alive", "Priority": 2, "Quota": 1, "Long Poll": "N", "Getworks": 1, "Accepted": 0, "Rejected": 0, "Works": 0, "Discarded": 0, "Stale": 0, "Get Failures": 0, "Remote Failures": 0, "User": "pool_username.real_worker", "Last Share Time": 0, "Diff1 Shares": 0, "Proxy Type": "", "Proxy": "", "Difficulty Accepted": 0.0, "Difficulty Rejected": 0.0, "Difficulty Stale": 0.0, "Last Share Difficulty": 0.0, "Work Difficulty": 16384.0, "Has Stratum": True, "Stratum Active": False, "Stratum URL": "stratum.pool.io", "Stratum Difficulty": 0.0, "Has Vmask": True, "Has GBT": False, "Best Share": 0, "Pool Rejected%": 0.0, "Pool Stale%": 0.0, "Bad Work": 0, "Current Block Height": 882586, "Current Block Version": 536870916, }, ], "id": 1, }, "rpc_stats": { "STATUS": [ { "STATUS": "S", "When": 986, "Code": 70, "Msg": "CGMiner stats", "Description": "cgminer 4.11.1", } ], "STATS": [ { "STATS": 0, "ID": "AVA100", "Elapsed": 975, "Calls": 0, "Wait": 0.0, "Max": 0.0, "Min": 99999999.0, "MM ID0": "Ver[15-194-24102401_25462b2_9ddf522] DNA[020100008c699117] MEMFREE[1392832.1381104] NETFAIL[0 0 0 0 0 0 0 0] SYSTEMSTATU[Work: In Work, Hash Board: 3 ] Elapsed[975] BOOTBY[0x04.00000000] LW[714031] MH[0 0 0] DHW[0] HW[0] DH[1.299%] Temp[31] TMax[78] TAvg[70] Fan1[4275] Fan2[4282] FanR[49%] Vo[296] PS[0 1209 1187 297 3526 1188 3731] WALLPOWER[3731] PLL0[3346 2549 4722 13703] PLL1[2620 2291 4741 14668] PLL2[1777 2019 3849 16675] GHSspd[199241.07] DHspd[1.299%] GHSmm[201920.42] GHSavg[184007.00] WU[2570548.05] Freq[345.94] Led[0] MGHS[59459.52 61407.83 63139.66] MTmax[77 78 77] MTavg[69 70 71] MVavg[285.7 286.3 285.8] TA[480] Core[A3197S] PING[131] POWS[0] EEPROM[160 160 160] HASHS[0 0 0] POOLS[0] SoftOFF[0] ECHU[0 0 0] ECMM[0] SF0[300 318 339 360] SF1[300 318 339 360] SF2[300 318 339 360] PVT_T0[ 66 65 63 62 64 64 66 65 67 68 65 64 62 64 66 68 66 64 63 63 64 65 65 66 68 66 64 64 65 67 66 68 65 65 64 62 64 67 66 66 65 65 64 65 61 66 66 65 65 65 64 61 61 65 66 66 66 68 65 64 63 63 64 66 65 64 62 64 65 64 65 67 66 68 64 62 60 63 66 64 68 68 70 71 73 73 73 69 70 74 73 73 76 75 73 71 70 73 74 74 76 76 75 71 69 74 73 74 72 72 71 68 69 71 74 73 73 75 74 69 69 74 75 75 73 74 70 70 68 70 72 70 77 75 73 71 73 72 74 74 75 75 71 68 71 71 72 75 74 73 71 69 69 71 71 71 72 74 70 69] PVT_T1[ 65 66 63 62 62 63 66 66 65 65 63 64 65 66 65 66 66 66 65 66 62 64 66 66 67 68 65 63 65 66 66 68 67 68 65 66 66 67 66 66 66 66 65 65 67 66 66 66 68 68 66 65 66 67 69 69 67 67 68 66 63 66 67 68 67 67 66 65 64 68 68 68 68 66 66 64 64 65 66 67 70 71 73 71 78 76 74 71 71 71 77 76 77 76 74 70 71 73 76 78 77 77 73 71 71 73 74 77 76 75 73 69 70 72 73 76 77 77 71 69 70 72 75 75 74 76 73 69 70 71 73 74 75 76 72 70 71 71 74 76 74 75 72 70 69 71 73 76 76 76 71 70 69 71 73 74 75 74 71 67] PVT_T2[ 67 66 66 63 69 67 67 69 66 70 67 68 66 71 68 69 69 67 67 68 69 69 68 67 69 68 68 70 70 71 68 69 71 68 70 69 71 66 68 70 67 66 67 71 69 67 68 67 69 68 68 69 66 69 69 67 70 66 67 67 67 67 66 69 70 66 71 68 67 69 68 69 70 68 69 68 70 67 67 68 72 71 74 74 74 74 72 71 70 74 76 75 74 76 76 71 73 74 76 77 77 75 74 73 72 72 77 76 73 75 74 71 71 71 73 74 74 75 72 70 69 73 74 74 74 74 74 71 71 72 73 74 75 75 74 74 73 72 77 75 75 75 72 72 71 72 74 75 75 74 74 71 69 72 74 74 74 73 70 68] PVT_V0[293 292 291 290 290 292 294 295 290 289 291 290 291 292 291 291 288 288 290 290 292 292 289 290 289 288 289 289 287 290 291 291 286 286 286 287 288 289 289 287 290 290 290 290 290 292 291 292 289 291 291 291 291 291 289 288 291 290 290 289 292 294 291 290 290 290 291 291 289 290 290 289 288 288 287 287 290 289 290 294 288 283 280 279 282 282 282 282 277 276 278 281 277 281 283 283 281 279 279 280 279 280 280 280 283 281 281 282 283 284 285 286 281 279 282 283 281 279 279 278 286 281 279 278 283 283 283 281 285 284 281 281 282 280 280 280 278 279 281 278 283 283 283 285 279 281 283 282 280 278 281 285 281 283 284 285 286 285 281 281] PVT_V1[293 292 293 290 292 293 292 292 291 290 292 291 291 291 291 291 291 293 290 290 291 292 292 293 290 290 292 292 289 289 289 287 291 291 291 290 289 289 288 287 290 289 289 289 291 291 290 291 292 291 289 288 288 289 288 289 289 290 288 288 290 289 290 290 291 291 291 291 288 289 287 287 291 291 288 288 288 289 291 294 286 283 282 281 278 282 280 283 282 282 278 279 282 280 283 281 281 278 280 278 279 281 282 282 283 282 282 283 286 285 285 284 284 281 282 282 279 280 283 281 283 282 282 282 279 284 282 284 284 282 282 282 283 282 282 284 285 283 283 282 283 283 283 283 280 282 281 281 283 284 284 286 285 285 286 287 286 286 283 285] PVT_V2[294 291 292 289 289 291 290 290 287 287 290 289 288 290 290 289 288 288 288 288 286 288 286 287 286 286 286 286 286 288 286 286 287 285 290 288 288 289 290 288 288 289 288 289 289 290 288 288 287 287 286 285 290 290 290 288 287 289 290 290 288 289 288 288 288 289 289 289 292 291 288 288 290 289 287 286 284 289 291 294 291 289 285 280 285 285 287 287 283 283 285 285 284 284 281 284 281 284 279 283 279 288 284 283 281 283 281 281 284 284 284 281 283 282 282 284 281 284 288 285 280 284 282 283 285 286 284 285 283 281 281 281 278 281 280 276 284 280 281 284 285 286 286 288 281 281 280 279 285 283 280 280 284 286 283 283 287 286 283 284] MW[238147 238178 238124] MW0[22 19 17 14 17 21 21 22 20 13 25 20 22 22 23 27 22 20 18 26 16 20 16 23 19 22 17 21 16 21 23 18 22 23 25 17 25 15 21 22 24 16 11 23 10 17 21 22 22 16 14 18 23 20 17 22 23 17 24 17 21 21 19 19 17 26 17 22 23 17 25 27 23 20 26 25 19 19 29 27 21 24 16 21 20 10 26 18 17 18 30 21 18 22 22 21 23 23 22 13 24 16 18 27 20 25 23 24 21 23 22 21 25 31 11 24 15 18 21 18 21 17 26 18 15 22 29 20 16 21 17 17 15 18 30 24 25 22 21 14 25 22 28 20 27 16 25 22 13 23 23 20 19 21 22 25 17 16 23 17] MW1[23 21 23 18 13 31 21 25 18 18 21 19 23 17 24 23 22 21 22 23 19 20 22 15 25 27 22 18 16 22 19 24 13 27 20 6 25 20 22 24 17 19 17 27 17 16 30 25 27 29 16 22 23 25 29 20 27 18 22 20 19 22 22 21 23 25 18 27 21 14 20 23 19 28 17 25 19 24 23 22 22 25 26 19 25 28 21 16 19 23 18 15 17 26 20 15 27 21 19 18 25 30 24 20 17 28 29 28 15 20 15 27 20 21 21 30 30 26 17 13 19 15 17 24 24 21 25 19 25 17 24 22 24 10 19 22 23 23 20 23 20 21 25 15 21 17 22 19 19 21 21 22 27 16 18 14 26 24 19 16] MW2[24 16 20 17 22 25 21 28 20 13 14 25 21 25 18 29 17 18 24 17 22 18 23 25 17 29 33 26 30 23 19 24 35 24 14 14 24 28 24 28 27 28 23 26 27 30 21 30 24 20 17 37 12 24 22 33 20 14 21 33 30 16 20 26 19 20 18 24 16 21 15 21 26 22 25 15 19 17 29 21 19 23 20 28 15 25 20 16 25 9 25 22 23 20 16 25 25 20 26 26 22 31 26 24 16 21 34 31 20 32 26 20 13 21 21 11 31 17 17 15 23 22 21 20 22 21 13 21 16 20 28 18 22 29 15 16 19 14 25 24 17 23 16 20 24 18 20 18 18 26 24 21 23 17 16 19 21 25 26 19] CRC[0 0 0] COMCRC[0 0 0] FACOPTS0[] FACOPTS1[] FACOPTS2[] ATAOPTS0[--avalon10-freq 240:258:279:300 --avalon10-voltage-level 1180 --hash-asic 160] ATAOPTS1[--avalon10-freq 300:318:339:360 --avalon10-voltage-level 1188 --hash-asic 160] ATAOPTS2[--avalon10-freq 300:318:339:360 --avalon10-voltage-level 1188 --hash-asic 160 --power-level 0] ADJ[1] COP[0 0 0] MPO[3515] MVL[87] ATABD0[300 318 339 360] ATABD1[300 318 339 360] ATABD2[300 318 339 360] WORKMODE[1]", "MM Count": 1, "Smart Speed": 1, "Voltage Level Offset": 0, "Nonce Mask": 25, }, { "STATS": 1, "ID": "POOL0", "Elapsed": 975, "Calls": 0, "Wait": 0.0, "Max": 0.0, "Min": 99999999.0, "Pool Calls": 0, "Pool Attempts": 0, "Pool Wait": 0.0, "Pool Max": 0.0, "Pool Min": 99999999.0, "Pool Av": 0.0, "Work Had Roll Time": False, "Work Can Roll": False, "Work Had Expire": False, "Work Roll Time": 0, "Work Diff": 262144.0, "Min Diff": 262144.0, "Max Diff": 262144.0, "Min Diff Count": 2, "Max Diff Count": 2, "Times Sent": 152, "Bytes Sent": 26720, "Times Recv": 181, "Bytes Recv": 62897, "Net Bytes Sent": 26720, "Net Bytes Recv": 62897, }, { "STATS": 2, "ID": "POOL1", "Elapsed": 975, "Calls": 0, "Wait": 0.0, "Max": 0.0, "Min": 99999999.0, "Pool Calls": 0, "Pool Attempts": 0, "Pool Wait": 0.0, "Pool Max": 0.0, "Pool Min": 99999999.0, "Pool Av": 0.0, "Work Had Roll Time": False, "Work Can Roll": False, "Work Had Expire": False, "Work Roll Time": 0, "Work Diff": 0.0, "Min Diff": 0.0, "Max Diff": 0.0, "Min Diff Count": 0, "Max Diff Count": 0, "Times Sent": 3, "Bytes Sent": 289, "Times Recv": 7, "Bytes Recv": 4954, "Net Bytes Sent": 289, "Net Bytes Recv": 4954, }, { "STATS": 3, "ID": "POOL2", "Elapsed": 975, "Calls": 0, "Wait": 0.0, "Max": 0.0, "Min": 99999999.0, "Pool Calls": 0, "Pool Attempts": 0, "Pool Wait": 0.0, "Pool Max": 0.0, "Pool Min": 99999999.0, "Pool Av": 0.0, "Work Had Roll Time": False, "Work Can Roll": False, "Work Had Expire": False, "Work Roll Time": 0, "Work Diff": 16384.0, "Min Diff": 16384.0, "Max Diff": 16384.0, "Min Diff Count": 1, "Max Diff Count": 1, "Times Sent": 3, "Bytes Sent": 257, "Times Recv": 6, "Bytes Recv": 1583, "Net Bytes Sent": 257, "Net Bytes Recv": 1583, }, ], "id": 1, }, "rpc_estats": { "STATUS": [ { "STATUS": "S", "When": 986, "Code": 70, "Msg": "CGMiner stats", "Description": "cgminer 4.11.1", } ], "STATS": [ { "STATS": 0, "ID": "AVA100", "Elapsed": 975, "Calls": 0, "Wait": 0.0, "Max": 0.0, "Min": 99999999.0, "MM ID0": "Ver[15-194-24102401_25462b2_9ddf522] DNA[020100008c699117] MEMFREE[1392832.1381104] NETFAIL[0 0 0 0 0 0 0 0] SYSTEMSTATU[Work: In Work, Hash Board: 3 ] Elapsed[975] BOOTBY[0x04.00000000] LW[714031] MH[0 0 0] DHW[0] HW[0] DH[1.299%] Temp[31] TMax[78] TAvg[70] Fan1[4275] Fan2[4282] FanR[49%] Vo[296] PS[0 1209 1187 297 3526 1188 3731] WALLPOWER[3731] PLL0[3346 2549 4722 13703] PLL1[2620 2291 4741 14668] PLL2[1777 2019 3849 16675] GHSspd[199241.07] DHspd[1.299%] GHSmm[201920.42] GHSavg[184007.00] WU[2570548.05] Freq[345.94] Led[0] MGHS[59459.52 61407.83 63139.66] MTmax[77 78 77] MTavg[69 70 71] MVavg[285.7 286.3 285.8] TA[480] Core[A3197S] PING[131] POWS[0] EEPROM[160 160 160] HASHS[0 0 0] POOLS[0] SoftOFF[0] ECHU[0 0 0] ECMM[0] SF0[300 318 339 360] SF1[300 318 339 360] SF2[300 318 339 360] PVT_T0[ 66 65 63 62 64 64 66 65 67 68 65 64 62 64 66 68 66 64 63 63 64 65 65 66 68 66 64 64 65 67 66 68 65 65 64 62 64 67 66 66 65 65 64 65 61 66 66 65 65 65 64 61 61 65 66 66 66 68 65 64 63 63 64 66 65 64 62 64 65 64 65 67 66 68 64 62 60 63 66 64 68 68 70 71 73 73 73 69 70 74 73 73 76 75 73 71 70 73 74 74 76 76 75 71 69 74 73 74 72 72 71 68 69 71 74 73 73 75 74 69 69 74 75 75 73 74 70 70 68 70 72 70 77 75 73 71 73 72 74 74 75 75 71 68 71 71 72 75 74 73 71 69 69 71 71 71 72 74 70 69] PVT_T1[ 65 66 63 62 62 63 66 66 65 65 63 64 65 66 65 66 66 66 65 66 62 64 66 66 67 68 65 63 65 66 66 68 67 68 65 66 66 67 66 66 66 66 65 65 67 66 66 66 68 68 66 65 66 67 69 69 67 67 68 66 63 66 67 68 67 67 66 65 64 68 68 68 68 66 66 64 64 65 66 67 70 71 73 71 78 76 74 71 71 71 77 76 77 76 74 70 71 73 76 78 77 77 73 71 71 73 74 77 76 75 73 69 70 72 73 76 77 77 71 69 70 72 75 75 74 76 73 69 70 71 73 74 75 76 72 70 71 71 74 76 74 75 72 70 69 71 73 76 76 76 71 70 69 71 73 74 75 74 71 67] PVT_T2[ 67 66 66 63 69 67 67 69 66 70 67 68 66 71 68 69 69 67 67 68 69 69 68 67 69 68 68 70 70 71 68 69 71 68 70 69 71 66 68 70 67 66 67 71 69 67 68 67 69 68 68 69 66 69 69 67 70 66 67 67 67 67 66 69 70 66 71 68 67 69 68 69 70 68 69 68 70 67 67 68 72 71 74 74 74 74 72 71 70 74 76 75 74 76 76 71 73 74 76 77 77 75 74 73 72 72 77 76 73 75 74 71 71 71 73 74 74 75 72 70 69 73 74 74 74 74 74 71 71 72 73 74 75 75 74 74 73 72 77 75 75 75 72 72 71 72 74 75 75 74 74 71 69 72 74 74 74 73 70 68] PVT_V0[293 292 291 290 290 292 294 295 290 289 291 290 291 292 291 291 288 288 290 290 292 292 289 290 289 288 289 289 287 290 291 291 286 286 286 287 288 289 289 287 290 290 290 290 290 292 291 292 289 291 291 291 291 291 289 288 291 290 290 289 292 294 291 290 290 290 291 291 289 290 290 289 288 288 287 287 290 289 290 294 288 283 280 279 282 282 282 282 277 276 278 281 277 281 283 283 281 279 279 280 279 280 280 280 283 281 281 282 283 284 285 286 281 279 282 283 281 279 279 278 286 281 279 278 283 283 283 281 285 284 281 281 282 280 280 280 278 279 281 278 283 283 283 285 279 281 283 282 280 278 281 285 281 283 284 285 286 285 281 281] PVT_V1[293 292 293 290 292 293 292 292 291 290 292 291 291 291 291 291 291 293 290 290 291 292 292 293 290 290 292 292 289 289 289 287 291 291 291 290 289 289 288 287 290 289 289 289 291 291 290 291 292 291 289 288 288 289 288 289 289 290 288 288 290 289 290 290 291 291 291 291 288 289 287 287 291 291 288 288 288 289 291 294 286 283 282 281 278 282 280 283 282 282 278 279 282 280 283 281 281 278 280 278 279 281 282 282 283 282 282 283 286 285 285 284 284 281 282 282 279 280 283 281 283 282 282 282 279 284 282 284 284 282 282 282 283 282 282 284 285 283 283 282 283 283 283 283 280 282 281 281 283 284 284 286 285 285 286 287 286 286 283 285] PVT_V2[294 291 292 289 289 291 290 290 287 287 290 289 288 290 290 289 288 288 288 288 286 288 286 287 286 286 286 286 286 288 286 286 287 285 290 288 288 289 290 288 288 289 288 289 289 290 288 288 287 287 286 285 290 290 290 288 287 289 290 290 288 289 288 288 288 289 289 289 292 291 288 288 290 289 287 286 284 289 291 294 291 289 285 280 285 285 287 287 283 283 285 285 284 284 281 284 281 284 279 283 279 288 284 283 281 283 281 281 284 284 284 281 283 282 282 284 281 284 288 285 280 284 282 283 285 286 284 285 283 281 281 281 278 281 280 276 284 280 281 284 285 286 286 288 281 281 280 279 285 283 280 280 284 286 283 283 287 286 283 284] MW[238147 238178 238124] MW0[22 19 17 14 17 21 21 22 20 13 25 20 22 22 23 27 22 20 18 26 16 20 16 23 19 22 17 21 16 21 23 18 22 23 25 17 25 15 21 22 24 16 11 23 10 17 21 22 22 16 14 18 23 20 17 22 23 17 24 17 21 21 19 19 17 26 17 22 23 17 25 27 23 20 26 25 19 19 29 27 21 24 16 21 20 10 26 18 17 18 30 21 18 22 22 21 23 23 22 13 24 16 18 27 20 25 23 24 21 23 22 21 25 31 11 24 15 18 21 18 21 17 26 18 15 22 29 20 16 21 17 17 15 18 30 24 25 22 21 14 25 22 28 20 27 16 25 22 13 23 23 20 19 21 22 25 17 16 23 17] MW1[23 21 23 18 13 31 21 25 18 18 21 19 23 17 24 23 22 21 22 23 19 20 22 15 25 27 22 18 16 22 19 24 13 27 20 6 25 20 22 24 17 19 17 27 17 16 30 25 27 29 16 22 23 25 29 20 27 18 22 20 19 22 22 21 23 25 18 27 21 14 20 23 19 28 17 25 19 24 23 22 22 25 26 19 25 28 21 16 19 23 18 15 17 26 20 15 27 21 19 18 25 30 24 20 17 28 29 28 15 20 15 27 20 21 21 30 30 26 17 13 19 15 17 24 24 21 25 19 25 17 24 22 24 10 19 22 23 23 20 23 20 21 25 15 21 17 22 19 19 21 21 22 27 16 18 14 26 24 19 16] MW2[24 16 20 17 22 25 21 28 20 13 14 25 21 25 18 29 17 18 24 17 22 18 23 25 17 29 33 26 30 23 19 24 35 24 14 14 24 28 24 28 27 28 23 26 27 30 21 30 24 20 17 37 12 24 22 33 20 14 21 33 30 16 20 26 19 20 18 24 16 21 15 21 26 22 25 15 19 17 29 21 19 23 20 28 15 25 20 16 25 9 25 22 23 20 16 25 25 20 26 26 22 31 26 24 16 21 34 31 20 32 26 20 13 21 21 11 31 17 17 15 23 22 21 20 22 21 13 21 16 20 28 18 22 29 15 16 19 14 25 24 17 23 16 20 24 18 20 18 18 26 24 21 23 17 16 19 21 25 26 19] CRC[0 0 0] COMCRC[0 0 0] FACOPTS0[] FACOPTS1[] FACOPTS2[] ATAOPTS0[--avalon10-freq 240:258:279:300 --avalon10-voltage-level 1180 --hash-asic 160] ATAOPTS1[--avalon10-freq 300:318:339:360 --avalon10-voltage-level 1188 --hash-asic 160] ATAOPTS2[--avalon10-freq 300:318:339:360 --avalon10-voltage-level 1188 --hash-asic 160 --power-level 0] ADJ[1] COP[0 0 0] MPO[3515] MVL[87] ATABD0[300 318 339 360] ATABD1[300 318 339 360] ATABD2[300 318 339 360] WORKMODE[1]", "MM Count": 1, "Smart Speed": 1, "Voltage Level Offset": 0, "Nonce Mask": 25, }, { "STATS": 1, "ID": "POOL0", "Elapsed": 975, "Calls": 0, "Wait": 0.0, "Max": 0.0, "Min": 99999999.0, "Pool Calls": 0, "Pool Attempts": 0, "Pool Wait": 0.0, "Pool Max": 0.0, "Pool Min": 99999999.0, "Pool Av": 0.0, "Work Had Roll Time": False, "Work Can Roll": False, "Work Had Expire": False, "Work Roll Time": 0, "Work Diff": 262144.0, "Min Diff": 262144.0, "Max Diff": 262144.0, "Min Diff Count": 2, "Max Diff Count": 2, "Times Sent": 152, "Bytes Sent": 26720, "Times Recv": 181, "Bytes Recv": 62897, "Net Bytes Sent": 26720, "Net Bytes Recv": 62897, }, { "STATS": 2, "ID": "POOL1", "Elapsed": 975, "Calls": 0, "Wait": 0.0, "Max": 0.0, "Min": 99999999.0, "Pool Calls": 0, "Pool Attempts": 0, "Pool Wait": 0.0, "Pool Max": 0.0, "Pool Min": 99999999.0, "Pool Av": 0.0, "Work Had Roll Time": False, "Work Can Roll": False, "Work Had Expire": False, "Work Roll Time": 0, "Work Diff": 0.0, "Min Diff": 0.0, "Max Diff": 0.0, "Min Diff Count": 0, "Max Diff Count": 0, "Times Sent": 3, "Bytes Sent": 289, "Times Recv": 7, "Bytes Recv": 4954, "Net Bytes Sent": 289, "Net Bytes Recv": 4954, }, { "STATS": 3, "ID": "POOL2", "Elapsed": 975, "Calls": 0, "Wait": 0.0, "Max": 0.0, "Min": 99999999.0, "Pool Calls": 0, "Pool Attempts": 0, "Pool Wait": 0.0, "Pool Max": 0.0, "Pool Min": 99999999.0, "Pool Av": 0.0, "Work Had Roll Time": False, "Work Can Roll": False, "Work Had Expire": False, "Work Roll Time": 0, "Work Diff": 16384.0, "Min Diff": 16384.0, "Max Diff": 16384.0, "Min Diff Count": 1, "Max Diff Count": 1, "Times Sent": 3, "Bytes Sent": 257, "Times Recv": 6, "Bytes Recv": 1583, "Net Bytes Sent": 257, "Net Bytes Recv": 1583, }, ], "id": 1, }, } } class TestAvalonMiners(unittest.IsolatedAsyncioTestCase): @patch("pyasic.rpc.base.BaseMinerRPCAPI._send_bytes") async def test_all_data_gathering(self, mock_send_bytes): mock_send_bytes.raises = APIError() for m_type in data: gathered_data = {} miner = m_type("127.0.0.1") for data_name in fields(miner.data_locations): if data_name.name == "config": # skip continue data_func = getattr(miner.data_locations, data_name.name) fn_args = data_func.kwargs args_to_send = {k.name: data[m_type][k.name] for k in fn_args} function = getattr(miner, data_func.cmd) gathered_data[data_name.name] = await function(**args_to_send) result = MinerData( ip=str(miner.ip), device_info=miner.device_info, expected_chips=( miner.expected_chips * miner.expected_hashboards if miner.expected_chips is not None else 0 ), expected_hashboards=miner.expected_hashboards, expected_fans=miner.expected_fans, hashboards=[ HashBoard(slot=i, expected_chips=miner.expected_chips) for i in range(miner.expected_hashboards) ], ) for item in gathered_data: if gathered_data[item] is not None: setattr(result, item, gathered_data[item]) self.assertEqual(result.mac, "12:34:56:78:90:12") self.assertEqual(result.api_ver, "3.7") self.assertEqual(result.fw_ver, "4.11.1") self.assertEqual(round(result.hashrate.into(SHA256Unit.TH)), 184) self.assertEqual( result.fans, [Fan(speed=4275), Fan(speed=4282)], ) self.assertEqual(result.total_chips, result.expected_chips) self.assertEqual( set([str(p.url) for p in result.pools]), set(p["url"] for p in POOLS) ) self.assertEqual(result.wattage, 3731) self.assertEqual(result.wattage_limit, 3515)
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/tests/miners_tests/backends_tests/avalonminer_tests/__init__.py
tests/miners_tests/backends_tests/avalonminer_tests/__init__.py
from .version_24102401_25462b2_9ddf522 import TestAvalonMiners
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/tests/miners_tests/backends_tests/hammer_tests/version_2023_05_28.py
tests/miners_tests/backends_tests/hammer_tests/version_2023_05_28.py
"""Tests for hammer miners with firmware dating 2023-05-28 17-20-35 CST""" import unittest from dataclasses import fields from unittest.mock import patch from pyasic import APIError, MinerData from pyasic.data import Fan, HashBoard from pyasic.device.algorithm.hashrate.unit.scrypt import ScryptUnit from pyasic.miners.hammer import HammerD10 POOLS = [ { "url": "stratum+tcp://stratum.pool.io:3333", "user": "pool_username.real_worker", "pwd": "123", }, { "url": "stratum+tcp://stratum.pool.io:3334", "user": "pool_username.real_worker", "pwd": "123", }, { "url": "stratum+tcp://stratum.pool.io:3335", "user": "pool_username.real_worker", "pwd": "123", }, ] data = { HammerD10: { "web_get_system_info": { "minertype": "Hammer D10", "nettype": "DHCP", "netdevice": "eth0", "macaddr": "12:34:56:78:90:12", "hostname": "Hammer", "ipaddress": "10.0.0.1", "netmask": "255.255.255.0", "gateway": "", "dnsservers": "", "curtime": "18:46:15", "uptime": "92", "loadaverage": "1.06, 1.36, 1.48", "mem_total": "251180", "mem_used": "64392", "mem_free": "186788", "mem_buffers": "0", "mem_cached": "0", "system_mode": "GNU/Linux", "bb_hwv": "2.0.2.2", "system_kernel_version": "Linux 3.8.13 #22 SMP Tue Dec 2 15:26:11 CST 2014", "system_filesystem_version": "2022-11-11 13-46-30 CST", "cgminer_version": "2.3.3", }, "rpc_version": { "STATUS": [ { "STATUS": "S", "When": 1730228015, "Code": 22, "Msg": "CGMiner versions", "Description": "ccminer 2.3.3", } ], "VERSION": [ { "CGMiner": "2.3.3", "API": "3.1", "Miner": "2.0.2.2", "CompileTime": "2023-05-28 17-20-35 CST", "Type": "Hammer D10", } ], "id": 1, }, "rpc_stats": { "STATUS": [ { "STATUS": "S", "When": 1730228065, "Code": 70, "Msg": "CGMiner stats", "Description": "ccminer 2.3.3", } ], "STATS": [ { "CGMiner": "2.3.3", "Miner": "2.0.2.2", "CompileTime": "2023-05-28 17-20-35 CST", "Type": "Hammer D10", }, { "STATS": 0, "ID": "A30", "Elapsed": 119161, "Calls": 0, "Wait": 0.000000, "Max": 0.000000, "Min": 99999999.000000, "MHS 5s": "4686.4886", "MHS av": "4872.8713", "miner_count": 3, "frequency": "810", "fan_num": 4, "fan1": 4650, "fan2": 4500, "fan3": 3870, "fan4": 3930, "temp_num": 12, "temp1": 21, "temp1": 42, "temp1": 21, "temp1": 45, "temp2": 21, "temp2": 40, "temp2": 23, "temp2": 42, "temp3": 18, "temp3": 39, "temp3": 20, "temp3": 40, "temp4": 0, "temp4": 0, "temp4": 0, "temp4": 0, "temp_max": 52, "Device Hardware%": 0.0000, "no_matching_work": 7978, "chain_acn1": 108, "chain_acn2": 108, "chain_acn3": 108, "chain_acn4": 0, "chain_acs1": " oooooooo oooooooo oooooooo oooooooo oooooooo oooooooo oooooooo oooooooo oooooooo oooooooo oooooooo oooooooo oooooooo oooo", "chain_acs2": " oooooooo oooooooo oooooooo oooooooo oooooooo oooooooo oooooooo oooooooo oooooooo oooooooo oooooooo oooooooo oooooooo oooo", "chain_acs3": " oooooooo oooooooo oooooooo oooooooo oooooooo oooooooo oooooooo oooooooo oooooooo oooooooo oooooooo oooooooo oooooooo oooo", "chain_acs4": "", "chain_hw1": 2133, "chain_hw2": 2942, "chain_hw3": 2903, "chain_hw4": 0, "chain_rate1": "1578.2742", "chain_rate2": "1594.3646", "chain_rate3": "1513.8498", "chain_rate4": "", }, ], "id": 1, }, "rpc_summary": { "STATUS": [ { "STATUS": "S", "When": 1730228038, "Code": 11, "Msg": "Summary", "Description": "ccminer 2.3.3", } ], "SUMMARY": [ { "Elapsed": 119134, "MHS 5s": "4885.0813", "MHS av": "4872.9297", "Found Blocks": 0, "Getworks": 8842, "Accepted": "156.0000", "Rejected": "156.0000", "Hardware Errors": 7977, "Utility": 6.71, "Discarded": 76514, "Stale": 0, "Get Failures": 0, "Local Work": 4123007, "Remote Failures": 0, "Network Blocks": 3323, "Total MH": 580531131.4496, "Work Utility": 4485762.79, "Difficulty Accepted": 8804959701.00000000, "Difficulty Rejected": 101813978.00000000, "Difficulty Stale": 0.00000000, "Best Share": 80831, "Device Hardware%": 0.0001, "Device Rejected%": 1.1431, "Pool Rejected%": 1.1431, "Pool Stale%": 0.0000, "Last getwork": 1730228038, } ], "id": 1, }, "web_summary": { "STATUS": { "STATUS": "S", "when": 1732121812.35528, "Msg": "summary", "api_version": "1.0.0", }, "INFO": { "miner_version": "49.0.1.3", "CompileTime": "Fri Sep 15 14:39:20 CST 2023", "type": "Antminer S19j", }, "SUMMARY": [ { "elapsed": 10023, "rate_5s": 102000.0, "rate_30m": 102000.0, "rate_avg": 102000.0, "rate_ideal": 102000.0, "rate_unit": "GH/s", "hw_all": 1598, "bestshare": 10000000000, "status": [ {"type": "rate", "status": "s", "code": 0, "msg": ""}, {"type": "network", "status": "s", "code": 0, "msg": ""}, {"type": "fans", "status": "s", "code": 0, "msg": ""}, {"type": "temp", "status": "s", "code": 0, "msg": ""}, ], } ], }, "web_get_blink_status": {"code": "B000"}, "web_get_conf": { "pools": [ { "url": p["url"], "user": p["user"], "pass": p["pwd"], } for p in POOLS ], "api-listen": True, "api-network": True, "api-groups": "A:stats:pools:devs:summary:version", "api-allow": "A:0/0,W:*", "bitmain-fan-ctrl": False, "bitmain-fan-pwm": "100", "bitmain-use-vil": True, "bitmain-freq": "675", "bitmain-voltage": "1400", "bitmain-ccdelay": "0", "bitmain-pwth": "0", "bitmain-work-mode": "0", "bitmain-freq-level": "", }, "rpc_pools": { "STATUS": [ { "Code": 7, "Description": "cgminer 1.0.0", "Msg": "3 Pool(s)", "STATUS": "S", "When": 1732121693, } ], "POOLS": [ { "Accepted": 10000, "Best Share": 1000000000.0, "Diff": "100K", "Diff1 Shares": 0, "Difficulty Accepted": 1000000000.0, "Difficulty Rejected": 1000000.0, "Difficulty Stale": 0.0, "Discarded": 100000, "Get Failures": 3, "Getworks": 9000, "Has GBT": False, "Has Stratum": True, "Last Share Difficulty": 100000.0, "Last Share Time": "0:00:02", "Long Poll": "N", "POOL": 0, "Pool Rejected%": 0.0, "Pool Stale%%": 0.0, "Priority": 0, "Proxy": "", "Proxy Type": "", "Quota": 1, "Rejected": 100, "Remote Failures": 0, "Stale": 0, "Status": "Alive", "Stratum Active": True, "Stratum URL": "stratum.pool.io", "URL": "stratum+tcp://stratum.pool.io:3333", "User": "pool_username.real_worker", }, { "Accepted": 10000, "Best Share": 1000000000.0, "Diff": "100K", "Diff1 Shares": 0, "Difficulty Accepted": 1000000000.0, "Difficulty Rejected": 1000000.0, "Difficulty Stale": 0.0, "Discarded": 100000, "Get Failures": 3, "Getworks": 9000, "Has GBT": False, "Has Stratum": True, "Last Share Difficulty": 100000.0, "Last Share Time": "0:00:02", "Long Poll": "N", "POOL": 1, "Pool Rejected%": 0.0, "Pool Stale%%": 0.0, "Priority": 0, "Proxy": "", "Proxy Type": "", "Quota": 1, "Rejected": 100, "Remote Failures": 0, "Stale": 0, "Status": "Alive", "Stratum Active": True, "Stratum URL": "stratum.pool.io", "URL": "stratum+tcp://stratum.pool.io:3333", "User": "pool_username.real_worker", }, { "Accepted": 10000, "Best Share": 1000000000.0, "Diff": "100K", "Diff1 Shares": 0, "Difficulty Accepted": 1000000000.0, "Difficulty Rejected": 1000000.0, "Difficulty Stale": 0.0, "Discarded": 100000, "Get Failures": 3, "Getworks": 9000, "Has GBT": False, "Has Stratum": True, "Last Share Difficulty": 100000.0, "Last Share Time": "0:00:02", "Long Poll": "N", "POOL": 2, "Pool Rejected%": 0.0, "Pool Stale%%": 0.0, "Priority": 0, "Proxy": "", "Proxy Type": "", "Quota": 1, "Rejected": 100, "Remote Failures": 0, "Stale": 0, "Status": "Alive", "Stratum Active": True, "Stratum URL": "stratum.pool.io", "URL": "stratum+tcp://stratum.pool.io:3333", "User": "pool_username.real_worker", }, ], "id": 1, }, } } class TestHammerMiners(unittest.IsolatedAsyncioTestCase): @patch("pyasic.rpc.base.BaseMinerRPCAPI._send_bytes") async def test_all_data_gathering(self, mock_send_bytes): mock_send_bytes.raises = APIError() for m_type in data: gathered_data = {} miner = m_type("127.0.0.1") for data_name in fields(miner.data_locations): if data_name.name == "config": # skip continue data_func = getattr(miner.data_locations, data_name.name) fn_args = data_func.kwargs args_to_send = {k.name: data[m_type][k.name] for k in fn_args} function = getattr(miner, data_func.cmd) gathered_data[data_name.name] = await function(**args_to_send) result = MinerData( ip=str(miner.ip), device_info=miner.device_info, expected_chips=( miner.expected_chips * miner.expected_hashboards if miner.expected_chips is not None else 0 ), expected_hashboards=miner.expected_hashboards, expected_fans=miner.expected_fans, hashboards=[ HashBoard(slot=i, expected_chips=miner.expected_chips) for i in range(miner.expected_hashboards) ], ) for item in gathered_data: if gathered_data[item] is not None: setattr(result, item, gathered_data[item]) self.assertEqual(result.mac, "12:34:56:78:90:12") self.assertEqual(result.api_ver, "3.1") self.assertEqual(result.fw_ver, "2023-05-28 17-20-35 CST") self.assertEqual(result.hostname, "Hammer") self.assertEqual(round(result.hashrate.into(ScryptUnit.MH)), 4686) self.assertEqual(result.fans, [Fan(speed=4650), Fan(speed=4500)]) self.assertEqual(result.total_chips, result.expected_chips)
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/tests/miners_tests/backends_tests/hammer_tests/__init__.py
tests/miners_tests/backends_tests/hammer_tests/__init__.py
from .version_2023_05_28 import TestHammerMiners
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/tests/miners_tests/backends_tests/mskminer_tests/version_2_6_0_39.py
tests/miners_tests/backends_tests/mskminer_tests/version_2_6_0_39.py
"""Tests for MSK miner firmware version 2.6.0.39""" import unittest from dataclasses import fields from unittest.mock import patch from pyasic import APIError, MinerData from pyasic.data import Fan, HashBoard from pyasic.device.algorithm import SHA256Unit from pyasic.miners.antminer import MSKMinerS19NoPIC POOLS = [ { "url": "stratum+tcp://stratum.pool.io:3333", "user": "pool_username.real_worker", "pwd": "123", }, { "url": "stratum+tcp://stratum.pool.io:3334", "user": "pool_username.real_worker", "pwd": "123", }, { "url": "stratum+tcp://stratum.pool.io:3335", "user": "pool_username.real_worker", "pwd": "123", }, ] data = { MSKMinerS19NoPIC: { "web_info_v1": { # needs updates with real data "network_info": { "result": { "address": "192.168.1.10", "macaddr": "12:34:56:78:90:12", "netmask": "255.255.255.0", } } }, "rpc_version": { "STATUS": [ { "STATUS": "S", "When": 1738856891, "Code": 22, "Msg": "BMMiner versions", "Description": "bmminer 1.0.0", } ], "VERSION": [ { "BMMiner": "4.11.1 rwglr", "API": "3.1", "Miner": "0.0.1.3", "CompileTime": "10 Dec 2024 14:34:31 GMT", "Type": "S19-88 v.2.6.0.39 ", } ], "id": 1, }, "rpc_stats": { "STATUS": [ { "STATUS": "S", "When": 1738856891, "Code": 70, "Msg": "BMMiner stats", "Description": "bmminer 1.0.0", } ], "STATS": [ { "BMMiner": "4.11.1 rwglr", "Miner": "0.0.1.3", "CompileTime": "10 Dec 2024 14:34:31 GMT", "Type": "S19-88 v.2.6.0.39 ", }, { "STATS": 0, "ID": "BC50", "Elapsed": 1926, "Calls": 0, "Wait": 0.000000, "Max": 0.000000, "Min": 99999999.000000, "GHS 5s": 99989.59, "GHS av": 99761.40, "miner_count": 3, "frequency": "", "fan_num": 4, "fan1": 5010, "fan2": 5160, "fan3": 5070, "fan4": 5040, "fan5": 0, "fan6": 0, "fan7": 0, "fan8": 0, "temp_num": 3, "temp1": 45, "temp2": 45, "temp3": 47, "temp4": 0, "temp5": 0, "temp6": 0, "temp7": 0, "temp8": 0, "temp9": 0, "temp10": 0, "temp11": 0, "temp12": 0, "temp13": 0, "temp14": 0, "temp15": 0, "temp16": 0, "temp2_1": 59, "temp2_2": 57, "temp2_3": 58, "temp2_4": 0, "temp2_5": 0, "temp2_6": 0, "temp2_7": 0, "temp2_8": 0, "temp2_9": 0, "temp2_10": 0, "temp2_11": 0, "temp2_12": 0, "temp2_13": 0, "temp2_14": 0, "temp2_15": 0, "temp2_16": 0, "temp3_1": 59, "temp3_2": 56, "temp3_3": 57, "temp3_4": 0, "temp3_5": 0, "temp3_6": 0, "temp3_7": 0, "temp3_8": 0, "temp3_9": 0, "temp3_10": 0, "temp3_11": 0, "temp3_12": 0, "temp3_13": 0, "temp3_14": 0, "temp3_15": 0, "temp3_16": 0, "temp_pcb1": "45-42-45-42", "temp_pcb2": "45-42-45-42", "temp_pcb3": "47-43-47-43", "temp_pcb4": "0-0-0-0", "temp_pcb5": "0-0-0-0", "temp_pcb6": "0-0-0-0", "temp_pcb7": "0-0-0-0", "temp_pcb8": "0-0-0-0", "temp_pcb9": "0-0-0-0", "temp_pcb10": "0-0-0-0", "temp_pcb11": "0-0-0-0", "temp_pcb12": "0-0-0-0", "temp_pcb13": "0-0-0-0", "temp_pcb14": "0-0-0-0", "temp_pcb15": "0-0-0-0", "temp_pcb16": "0-0-0-0", "temp_chip1": "59-59-59-59", "temp_chip2": "57-56-57-56", "temp_chip3": "58-57-58-57", "temp_chip4": "0-0-0-0", "temp_chip5": "0-0-0-0", "temp_chip6": "0-0-0-0", "temp_chip7": "0-0-0-0", "temp_chip8": "0-0-0-0", "temp_chip9": "0-0-0-0", "temp_chip10": "0-0-0-0", "temp_chip11": "0-0-0-0", "temp_chip12": "0-0-0-0", "temp_chip13": "0-0-0-0", "temp_chip14": "0-0-0-0", "temp_chip15": "0-0-0-0", "temp_chip16": "0-0-0-0", "total_rateideal": 99674.88, "total_freqavg": 0.00, "total_acn": 264, "total_rate": 99989.59, "chain_rateideal1": 33677.28, "chain_rateideal2": 32788.06, "chain_rateideal3": 33209.54, "chain_rateideal4": 31436.24, "chain_rateideal5": 31436.24, "chain_rateideal6": 31436.24, "chain_rateideal7": 31436.24, "chain_rateideal8": 31436.24, "chain_rateideal9": 31436.24, "chain_rateideal10": 31436.24, "chain_rateideal11": 31436.24, "chain_rateideal12": 31436.24, "chain_rateideal13": 31436.24, "chain_rateideal14": 31436.24, "chain_rateideal15": 31436.24, "chain_rateideal16": 31436.24, "temp_max": 47, "no_matching_work": 0, "chain_acn1": 88, "chain_acn2": 88, "chain_acn3": 88, "chain_acn4": 0, "chain_acn5": 0, "chain_acn6": 0, "chain_acn7": 0, "chain_acn8": 0, "chain_acn9": 0, "chain_acn10": 0, "chain_acn11": 0, "chain_acn12": 0, "chain_acn13": 0, "chain_acn14": 0, "chain_acn15": 0, "chain_acn16": 0, "chain_acs1": " oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo", "chain_acs2": " oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo", "chain_acs3": " oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo", "chain_acs4": "", "chain_acs5": "", "chain_acs6": "", "chain_acs7": "", "chain_acs8": "", "chain_acs9": "", "chain_acs10": "", "chain_acs11": "", "chain_acs12": "", "chain_acs13": "", "chain_acs14": "", "chain_acs15": "", "chain_acs16": "", "chain_hw1": 0, "chain_hw2": 0, "chain_hw3": 0, "chain_hw4": 0, "chain_hw5": 0, "chain_hw6": 0, "chain_hw7": 0, "chain_hw8": 0, "chain_hw9": 0, "chain_hw10": 0, "chain_hw11": 0, "chain_hw12": 0, "chain_hw13": 0, "chain_hw14": 0, "chain_hw15": 0, "chain_hw16": 0, "chain_rate1": 34084.86, "chain_rate2": 32303.65, "chain_rate3": 33601.08, "chain_rate4": 0.00, "chain_rate5": 0.00, "chain_rate6": 0.00, "chain_rate7": 0.00, "chain_rate8": 0.00, "chain_rate9": 0.00, "chain_rate10": 0.00, "chain_rate11": 0.00, "chain_rate12": 0.00, "chain_rate13": 0.00, "chain_rate14": 0.00, "chain_rate15": 0.00, "chain_rate16": 0.00, "chain_xtime1": "{}", "chain_xtime2": "{}", "chain_xtime3": "{}", "chain_offside_1": "", "chain_offside_2": "", "chain_offside_3": "", "chain_opencore_0": "1", "chain_opencore_1": "1", "chain_opencore_2": "1", "freq1": 744, "freq2": 724, "freq3": 734, "freq4": 0, "freq5": 0, "freq6": 0, "freq7": 0, "freq8": 0, "freq9": 0, "freq10": 0, "freq11": 0, "freq12": 0, "freq13": 0, "freq14": 0, "freq15": 0, "freq16": 0, "chain_avgrate1": 33585.34, "chain_avgrate2": 32788.97, "chain_avgrate3": 33336.44, "chain_avgrate4": 0.00, "chain_avgrate5": 0.00, "chain_avgrate6": 0.00, "chain_avgrate7": 0.00, "chain_avgrate8": 0.00, "chain_avgrate9": 0.00, "chain_avgrate10": 0.00, "chain_avgrate11": 0.00, "chain_avgrate12": 0.00, "chain_avgrate13": 0.00, "chain_avgrate14": 0.00, "chain_avgrate15": 0.00, "chain_avgrate16": 0.00, "miner_version": "0.0.1.3", "miner_id": "", "chain_power1": 1135, "chain_power2": 1103, "chain_power3": 1118, "total_power": 3358, "chain_voltage1": 15.70, "chain_voltage2": 15.70, "chain_voltage3": 15.70, "chain_voltage4": 15.70, "chain_voltage5": 15.70, "chain_voltage6": 15.70, "chain_voltage7": 15.70, "chain_voltage8": 15.70, "chain_voltage9": 15.70, "chain_voltage10": 15.70, "chain_voltage11": 15.70, "chain_voltage12": 15.70, "chain_voltage13": 15.70, "chain_voltage14": 15.70, "chain_voltage15": 15.70, "chain_voltage16": 15.70, "fan_pwm": 82, "bringup_temp": 16, "has_pic": "1", "tune_running": "0", "psu_status": "PSU OK", "downscale_mode": "0", "has_hotel_fee": "0", }, ], "id": 1, }, "rpc_pools": { "STATUS": [ { "Code": 7, "Description": "cgminer 1.0.0", "Msg": "3 Pool(s)", "STATUS": "S", "When": 1732121693, } ], "POOLS": [ { "Accepted": 10000, "Best Share": 1000000000.0, "Diff": "100K", "Diff1 Shares": 0, "Difficulty Accepted": 1000000000.0, "Difficulty Rejected": 1000000.0, "Difficulty Stale": 0.0, "Discarded": 100000, "Get Failures": 3, "Getworks": 9000, "Has GBT": False, "Has Stratum": True, "Last Share Difficulty": 100000.0, "Last Share Time": "0:00:02", "Long Poll": "N", "POOL": 0, "Pool Rejected%": 0.0, "Pool Stale%%": 0.0, "Priority": 0, "Proxy": "", "Proxy Type": "", "Quota": 1, "Rejected": 100, "Remote Failures": 0, "Stale": 0, "Status": "Alive", "Stratum Active": True, "Stratum URL": "stratum.pool.io", "URL": "stratum+tcp://stratum.pool.io:3333", "User": "pool_username.real_worker", }, { "Accepted": 10000, "Best Share": 1000000000.0, "Diff": "100K", "Diff1 Shares": 0, "Difficulty Accepted": 1000000000.0, "Difficulty Rejected": 1000000.0, "Difficulty Stale": 0.0, "Discarded": 100000, "Get Failures": 3, "Getworks": 9000, "Has GBT": False, "Has Stratum": True, "Last Share Difficulty": 100000.0, "Last Share Time": "0:00:02", "Long Poll": "N", "POOL": 1, "Pool Rejected%": 0.0, "Pool Stale%%": 0.0, "Priority": 0, "Proxy": "", "Proxy Type": "", "Quota": 1, "Rejected": 100, "Remote Failures": 0, "Stale": 0, "Status": "Alive", "Stratum Active": True, "Stratum URL": "stratum.pool.io", "URL": "stratum+tcp://stratum.pool.io:3333", "User": "pool_username.real_worker", }, { "Accepted": 10000, "Best Share": 1000000000.0, "Diff": "100K", "Diff1 Shares": 0, "Difficulty Accepted": 1000000000.0, "Difficulty Rejected": 1000000.0, "Difficulty Stale": 0.0, "Discarded": 100000, "Get Failures": 3, "Getworks": 9000, "Has GBT": False, "Has Stratum": True, "Last Share Difficulty": 100000.0, "Last Share Time": "0:00:02", "Long Poll": "N", "POOL": 2, "Pool Rejected%": 0.0, "Pool Stale%%": 0.0, "Priority": 0, "Proxy": "", "Proxy Type": "", "Quota": 1, "Rejected": 100, "Remote Failures": 0, "Stale": 0, "Status": "Alive", "Stratum Active": True, "Stratum URL": "stratum.pool.io", "URL": "stratum+tcp://stratum.pool.io:3333", "User": "pool_username.real_worker", }, ], "id": 1, }, } } class TestMSKMiners(unittest.IsolatedAsyncioTestCase): @patch("pyasic.rpc.base.BaseMinerRPCAPI._send_bytes") async def test_all_data_gathering(self, mock_send_bytes): mock_send_bytes.raises = APIError() for m_type in data: gathered_data = {} miner = m_type("127.0.0.1") for data_name in fields(miner.data_locations): if data_name.name == "config": # skip continue data_func = getattr(miner.data_locations, data_name.name) fn_args = data_func.kwargs args_to_send = {k.name: data[m_type][k.name] for k in fn_args} function = getattr(miner, data_func.cmd) gathered_data[data_name.name] = await function(**args_to_send) result = MinerData( ip=str(miner.ip), device_info=miner.device_info, expected_chips=( miner.expected_chips * miner.expected_hashboards if miner.expected_chips is not None else 0 ), expected_hashboards=miner.expected_hashboards, expected_fans=miner.expected_fans, hashboards=[ HashBoard(slot=i, expected_chips=miner.expected_chips) for i in range(miner.expected_hashboards) ], ) for item in gathered_data: if gathered_data[item] is not None: setattr(result, item, gathered_data[item]) self.assertEqual(result.mac, "12:34:56:78:90:12") self.assertEqual(result.api_ver, "3.1") self.assertEqual(result.fw_ver, "10 Dec 2024 14:34:31 GMT") self.assertEqual(round(result.hashrate.into(SHA256Unit.TH)), 100) self.assertEqual( result.fans, [Fan(speed=5010), Fan(speed=5160), Fan(speed=5070), Fan(speed=5040)], ) self.assertEqual(result.total_chips, result.expected_chips)
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/tests/miners_tests/backends_tests/mskminer_tests/__init__.py
tests/miners_tests/backends_tests/mskminer_tests/__init__.py
from .version_2_6_0_39 import TestMSKMiners
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/tests/miners_tests/backends_tests/elphapex_tests/__init__.py
tests/miners_tests/backends_tests/elphapex_tests/__init__.py
from .version_1_0_2 import TestElphapexMiners
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/tests/miners_tests/backends_tests/elphapex_tests/version_1_0_2.py
tests/miners_tests/backends_tests/elphapex_tests/version_1_0_2.py
"""Tests for hammer miners with firmware dating 2023-05-28 17-20-35 CST""" import unittest from dataclasses import fields from unittest.mock import patch from pyasic import APIError, MinerData from pyasic.data import Fan, HashBoard from pyasic.device.algorithm.hashrate.unit.scrypt import ScryptUnit from pyasic.miners.elphapex import ElphapexDG1Plus POOLS = [ { "url": "stratum+tcp://stratum.pool.io:3333", "user": "pool_username.real_worker", "pwd": "123", }, { "url": "stratum+tcp://stratum.pool.io:3334", "user": "pool_username.real_worker", "pwd": "123", }, { "url": "stratum+tcp://stratum.pool.io:3335", "user": "pool_username.real_worker", "pwd": "123", }, ] data = { ElphapexDG1Plus: { "web_get_system_info": { "ipaddress": "172.19.203.183", "system_mode": "GNU/Linux", "netmask": "255.255.255.0", "gateway": "", "Algorithm": "Scrypt", "system_kernel_version": "4.4.194 #1 SMP Sat Sep 7 16:59:20 CST 2024", "system_filesystem_version": "DG1+_SW_V1.0.2", "nettype": "DHCP", "dnsservers": "", "netdevice": "eth0", "minertype": "DG1+", "macaddr": "12:34:56:78:90:12", "firmware_type": "Release", "hostname": "DG1+", }, "web_summary": { "STATUS": { "STATUS": "S", "when": 2557706, "timestamp": 1731569527, "api_version": "1.0.0", "Msg": "summary", }, "SUMMARY": [ { "rate_unit": "MH/s", "elapsed": 357357, "rate_30m": 0, "rate_5s": 14920.940000000001, "bestshare": 0, "rate_ideal": 14229, "status": [ {"status": "s", "type": "rate", "msg": "", "code": 0}, {"status": "s", "type": "network", "msg": "", "code": 0}, {"status": "s", "type": "fans", "msg": "", "code": 0}, {"status": "s", "type": "temp", "msg": "", "code": 0}, ], "hw_all": 14199.040000000001, "rate_avg": 14199.040000000001, "rate_15m": 14415, } ], "INFO": { "miner_version": "DG1+_SW_V1.0.2", "CompileTime": "", "dev_sn": "28HY245192N000245C23B", "type": "DG1+", "hw_version": "DG1+_HW_V1.0", }, }, "web_stats": { "STATUS": { "STATUS": "S", "when": 2557700, "timestamp": 1731569521, "api_version": "1.0.0", "Msg": "stats", }, "INFO": { "miner_version": "DG1+_SW_V1.0.2", "CompileTime": "", "dev_sn": "28HY245192N000245C23B", "type": "DG1+", "hw_version": "DG1+_HW_V1.0", }, "STATS": [ { "rate_unit": "MH/s", "elapsed": 357352, "rate_30m": 0, "rate_5s": 11531.879999999999, "hwp_total": 0.11550000000000001, "rate_ideal": 14229, "chain": [ { "freq_avg": 62000, "index": 0, "sn": "13HY245156N000581H11JB52", "temp_chip": ["47125", "50500", "", ""], "eeprom_loaded": True, "rate_15m": 3507, "hw": 204, "temp_pcb": [47, 46, 67, 66], "failrate": 0.029999999999999999, "asic": "ooooooooo oooooooo oooooooo oooooooo oooo", "rate_real": 3553.5, "asic_num": 204, "temp_pic": [47, 46, 67, 66], "rate_ideal": 3557.25, "hashrate": 3278.5999999999999, }, { "freq_avg": 62000, "index": 1, "sn": "13HY245156N000579H11JB52", "temp_chip": ["52812", "56937", "", ""], "eeprom_loaded": True, "rate_15m": 3736, "hw": 204, "temp_pcb": [47, 46, 67, 66], "failrate": 0.02, "asic": "ooooooooo oooooooo oooooooo oooooooo oooo", "rate_real": 3550.1100000000001, "asic_num": 204, "temp_pic": [47, 46, 67, 66], "rate_ideal": 3557.25, "hashrate": 3491.8400000000001, }, { "freq_avg": 62000, "index": 2, "sn": "13HY245156N000810H11JB52", "temp_chip": ["48312", "51687", "", ""], "eeprom_loaded": True, "rate_15m": 3531, "hw": 204, "temp_pcb": [47, 46, 67, 66], "failrate": 0.51000000000000001, "asic": "ooooooooo oooooooo oooooooo oooooooo oooo", "rate_real": 3551.8000000000002, "asic_num": 204, "temp_pic": [47, 46, 67, 66], "rate_ideal": 3557.25, "hashrate": 3408.6999999999998, }, { "freq_avg": 62000, "index": 3, "sn": "13HY245156N000587H11JB52", "temp_chip": ["46500", "49062", "", ""], "eeprom_loaded": True, "rate_15m": 3641, "hw": 204, "temp_pcb": [47, 46, 67, 66], "failrate": 0.029999999999999999, "asic": "ooooooooo oooooooo oooooooo oooooooo oooo", "rate_real": 3543.6300000000001, "asic_num": 204, "temp_pic": [47, 46, 67, 66], "rate_ideal": 3557.25, "hashrate": 3463.6799999999998, }, ], "rate_15m": 14415, "chain_num": 4, "fan": ["5340", "5400", "5400", "5400"], "rate_avg": 14199.040000000001, "fan_num": 4, } ], }, "web_get_blink_status": {"blink": False}, "web_get_miner_conf": { "pools": [ { "url": "stratum+tcp://ltc.trustpool.ru:3333", "pass": "123", "user": "Nikita9231.fworker", }, { "url": "stratum+tcp://ltc.trustpool.ru:443", "pass": "123", "user": "Nikita9231.fworker", }, { "url": "stratum+tcp://ltc.trustpool.ru:25", "pass": "123", "user": "Nikita9231.fworker", }, ], "fc-voltage": "1470", "fc-fan-ctrl": False, "fc-freq-level": "100", "fc-fan-pwm": "80", "algo": "ltc", "fc-work-mode": 0, "fc-freq": "1850", }, "web_pools": { "STATUS": { "STATUS": "S", "when": 5411762, "timestamp": 1738768594, "api_version": "1.0.0", "Msg": "pools", }, "Device Total Rejected": 8888, "POOLS": [ { "diffs": 0, "diffr": 524288, "index": 0, "user": "pool_username.real_worker", "lsdiff": 524288, "lstime": "00:00:18", "diffa": 524288, "accepted": 798704, "diff1": 0, "stale": 0, "diff": "", "rejected": 3320, "status": "Unreachable", "getworks": 802024, "priority": 0, "url": "stratum+tcp://stratum.pool.io:3333", }, { "diffs": 0, "diffr": 524288, "index": 1, "user": "pool_username.real_worker", "lsdiff": 524288, "lstime": "00:00:00", "diffa": 524288, "accepted": 604803, "diff1": 0, "stale": 0, "diff": "", "rejected": 2492, "status": "Alive", "getworks": 607295, "priority": 1, "url": "stratum+tcp://stratum.pool.io:3334", }, { "diffs": 0, "diffr": 524288, "index": 2, "user": "pool_username.real_worker", "lsdiff": 524288, "lstime": "00:00:05", "diffa": 524288, "accepted": 691522, "diff1": 0, "stale": 0, "diff": "", "rejected": 3076, "status": "Unreachable", "getworks": 694598, "priority": 2, "url": "stratum+tcp://stratum.pool.io:3335", }, ], "Device Rejected%": 0.41999999999999998, "Device Total Work": 2103917, "INFO": { "miner_version": "DG1+_SW_V1.0.2", "CompileTime": "", "dev_sn": "28HY245192N000245C23B", "type": "DG1+", "hw_version": "DG1+_HW_V1.0", }, }, } } class TestElphapexMiners(unittest.IsolatedAsyncioTestCase): @patch("pyasic.rpc.base.BaseMinerRPCAPI._send_bytes") async def test_all_data_gathering(self, mock_send_bytes): mock_send_bytes.raises = APIError() for m_type in data: gathered_data = {} miner = m_type("127.0.0.1") for data_name in fields(miner.data_locations): if data_name.name == "config": # skip continue data_func = getattr(miner.data_locations, data_name.name) fn_args = data_func.kwargs args_to_send = {k.name: data[m_type][k.name] for k in fn_args} function = getattr(miner, data_func.cmd) gathered_data[data_name.name] = await function(**args_to_send) result = MinerData( ip=str(miner.ip), device_info=miner.device_info, expected_chips=( miner.expected_chips * miner.expected_hashboards if miner.expected_chips is not None else 0 ), expected_hashboards=miner.expected_hashboards, expected_fans=miner.expected_fans, hashboards=[ HashBoard(slot=i, expected_chips=miner.expected_chips) for i in range(miner.expected_hashboards) ], ) for item in gathered_data: if gathered_data[item] is not None: setattr(result, item, gathered_data[item]) self.assertEqual(result.mac, "12:34:56:78:90:12") self.assertEqual(result.api_ver, "1.0.0") self.assertEqual(result.fw_ver, "1.0.2") self.assertEqual(result.hostname, "DG1+") self.assertEqual(round(result.hashrate.into(ScryptUnit.MH)), 14199) self.assertEqual( result.fans, [Fan(speed=5340), Fan(speed=5400), Fan(speed=5400), Fan(speed=5400)], ) self.assertEqual(result.total_chips, result.expected_chips) self.assertEqual( set([str(p.url) for p in result.pools]), set(p["url"] for p in POOLS) )
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/tests/config_tests/fans.py
tests/config_tests/fans.py
import unittest from pyasic.config import FanModeConfig class TestFanConfig(unittest.TestCase): def test_serialize_and_deserialize(self): for fan_mode in FanModeConfig: with self.subTest( msg="Test serialization and deserialization of fan config", fan_mode=fan_mode, ): conf = fan_mode() dict_conf = conf.as_dict() self.assertEqual(conf, FanModeConfig.from_dict(dict_conf)) def test_bosminer_deserialize_and_serialize(self): for fan_mode in FanModeConfig: with self.subTest( msg="Test serialization and deserialization of bosminer fan config", fan_mode=fan_mode, ): conf = fan_mode() bos_conf = conf.as_bosminer() self.assertEqual(conf, FanModeConfig.from_bosminer(bos_conf)) def test_am_modern_deserialize_and_serialize(self): for fan_mode in FanModeConfig: with self.subTest( msg="Test serialization and deserialization of antminer modern fan config", fan_mode=fan_mode, ): conf = fan_mode() am_conf = conf.as_am_modern() self.assertEqual(conf, FanModeConfig.from_am_modern(am_conf)) def test_epic_deserialize_and_serialize(self): for fan_mode in FanModeConfig: with self.subTest( msg="Test serialization and deserialization of epic fan config", fan_mode=fan_mode, ): conf = fan_mode() epic_conf = conf.as_epic() self.assertEqual(conf, FanModeConfig.from_epic(epic_conf)) def test_vnish_deserialize_and_serialize(self): for fan_mode in FanModeConfig: with self.subTest( msg="Test serialization and deserialization of vnish fan config", fan_mode=fan_mode, ): conf = fan_mode() vnish_conf = conf.as_vnish() self.assertEqual(conf, FanModeConfig.from_vnish(vnish_conf)) def test_auradine_deserialize_and_serialize(self): for fan_mode in FanModeConfig: with self.subTest( msg="Test serialization and deserialization of auradine fan config", fan_mode=fan_mode, ): conf = fan_mode() aur_conf = conf.as_auradine() self.assertEqual(conf, FanModeConfig.from_auradine(aur_conf)) def test_boser_deserialize_and_serialize(self): for fan_mode in FanModeConfig: with self.subTest( msg="Test serialization and deserialization of boser fan config", fan_mode=fan_mode, ): conf = fan_mode() boser_conf = conf.as_boser self.assertEqual(conf, FanModeConfig.from_boser(boser_conf))
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/tests/config_tests/__init__.py
tests/config_tests/__init__.py
# ------------------------------------------------------------------------------ # 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. - # ------------------------------------------------------------------------------ import unittest from pyasic.config import ( FanModeConfig, MinerConfig, MiningModeConfig, PoolConfig, ScalingConfig, TemperatureConfig, ) from pyasic.config.mining.scaling import ScalingShutdown class TestConfig(unittest.TestCase): def setUp(self): self.cfg = MinerConfig( pools=PoolConfig.simple( [ { "url": "stratum+tcp://stratum.test.io:3333", "user": "test.test", "password": "123", } ] ), fan_mode=FanModeConfig.manual(speed=90, minimum_fans=2), temperature=TemperatureConfig(target=70, danger=120), mining_mode=MiningModeConfig.power_tuning( power=3000, scaling=ScalingConfig( step=100, minimum=2000, shutdown=ScalingShutdown(enabled=True, duration=3), ), ), ) def test_dict_deserialize_and_serialize(self): dict_config = self.cfg.as_dict() loaded_cfg = MinerConfig.from_dict(dict_config) self.assertEqual(loaded_cfg, self.cfg) def test_dict_serialize_and_deserialize(self): dict_config = { "pools": { "groups": [ { "pools": [ { "url": "stratum+tcp://stratum.test.io:3333", "user": "test.test", "password": "123", } ], "quota": 1, "name": "B6SPD2", } ] }, "fan_mode": {"mode": "manual", "speed": 90, "minimum_fans": 2}, "temperature": {"target": 70, "hot": None, "danger": 120}, "mining_mode": { "mode": "power_tuning", "power": 3000, "algo": {"mode": "standard"}, "scaling": { "step": 100, "minimum": 2000, "shutdown": {"enabled": True, "duration": 3}, }, }, } loaded_config = MinerConfig.from_dict(dict_config) dumped_config = loaded_config.as_dict() self.assertEqual(dumped_config, dict_config) def test_bosminer_deserialize_and_serialize(self): bosminer_config = self.cfg.as_bosminer() loaded_config = MinerConfig.from_bosminer(bosminer_config) self.assertEqual(loaded_config, self.cfg) def test_bosminer_serialize_and_deserialize(self): bosminer_config = { "temp_control": { "mode": "manual", "target_temp": 70, "dangerous_temp": 120, }, "fan_control": {"min_fans": 2, "speed": 90}, "autotuning": { "enabled": True, "mode": "power_target", "power_target": 3000, }, "group": [ { "name": "W91Q1L", "pool": [ { "url": "statum+tcp://stratum.test.io:3333", "user": "test.test", "password": "123", } ], "quota": 1, } ], "performance_scaling": { "enabled": True, "power_step": 100, "min_power_target": 2000, "shutdown_enabled": True, "shutdown_duration": 3, }, } loaded_config = MinerConfig.from_bosminer(bosminer_config) dumped_config = loaded_config.as_bosminer() self.assertEqual(dumped_config, bosminer_config) def test_am_modern_serialize(self): correct_config = { "bitmain-fan-ctrl": True, "bitmain-fan-pwm": "90", "freq-level": "100", "miner-mode": 0, "pools": [ { "url": "stratum+tcp://stratum.test.io:3333", "user": "test.test", "pass": "123", }, {"url": "", "user": "", "pass": ""}, {"url": "", "user": "", "pass": ""}, ], } self.assertEqual(correct_config, self.cfg.as_am_modern()) def test_am_old_serialize(self): correct_config = { "_ant_pool1url": "stratum+tcp://stratum.test.io:3333", "_ant_pool1user": "test.test", "_ant_pool1pw": "123", "_ant_pool2url": "", "_ant_pool2user": "", "_ant_pool2pw": "", "_ant_pool3url": "", "_ant_pool3user": "", "_ant_pool3pw": "", } self.assertEqual(correct_config, self.cfg.as_am_old()) def test_wm_serialize(self): correct_config = { "mode": "power_tuning", "power_tuning": {"wattage": 3000}, "pools": { "pool_1": "stratum+tcp://stratum.test.io:3333", "worker_1": "test.test", "passwd_1": "123", "pool_2": "", "worker_2": "", "passwd_2": "", "pool_3": "", "worker_3": "", "passwd_3": "", }, } self.assertEqual(correct_config, self.cfg.as_wm()) def test_goldshell_serialize(self): correct_config = { "pools": [ { "url": "stratum+tcp://stratum.test.io:3333", "user": "test.test", "pass": "123", } ] } self.assertEqual(correct_config, self.cfg.as_goldshell()) def test_avalon_serialize(self): correct_config = {"pools": "stratum+tcp://stratum.test.io:3333,test.test,123"} self.assertEqual(correct_config, self.cfg.as_avalon()) def test_inno_serialize(self): correct_config = { "Pool1": "stratum+tcp://stratum.test.io:3333", "UserName1": "test.test", "Password1": "123", "Pool2": "", "UserName2": "", "Password2": "", "Pool3": "", "UserName3": "", "Password3": "", } self.assertEqual(correct_config, self.cfg.as_inno()) if __name__ == "__main__": unittest.main()
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/tests/rpc_tests/__init__.py
tests/rpc_tests/__init__.py
# ------------------------------------------------------------------------------ # 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. - # ------------------------------------------------------------------------------ import json import time import unittest from unittest.mock import patch from pyasic import APIError from pyasic.rpc.bfgminer import BFGMinerRPCAPI from pyasic.rpc.bmminer import BMMinerRPCAPI from pyasic.rpc.bosminer import BOSMinerRPCAPI from pyasic.rpc.btminer import BTMinerRPCAPI from pyasic.rpc.cgminer import CGMinerRPCAPI from pyasic.rpc.gcminer import GCMinerRPCAPI from pyasic.rpc.luxminer import LUXMinerRPCAPI class TestAPIBase(unittest.IsolatedAsyncioTestCase): def setUp(self): self.ip = "10.0.0.50" self.port = 4028 self.api_str = "" self.api = None self.setUpData() def setUpData(self): pass def get_error_value(self): return json.dumps( { "STATUS": [ {"STATUS": "E", "When": time.time(), "Code": 7, "Msg": self.api_str} ], "id": 1, } ).encode("utf-8") def get_success_value(self, command: str): if self.api_str == "BTMiner": if command == "status": return json.dumps( { "STATUS": "S", "When": 1706287567, "Code": 131, "Msg": { "mineroff": "false", "mineroff_reason": "", "mineroff_time": "", "FirmwareVersion": "20230911.12.Rel", "power_mode": "", "hash_percent": "", }, "Description": "", } ).encode("utf-8") elif command == "get_token": # Return proper token response for BTMiner matching real miner format return json.dumps( { "STATUS": "S", "When": int(time.time()), "Code": 134, "Msg": { "time": str(int(time.time())), "salt": "D6w5gVOb", # Valid salt format (alphanumeric only) "newsalt": "zU4gvW30", # Valid salt format (alphanumeric only) }, "Description": "", } ).encode("utf-8") return json.dumps( { "STATUS": [ { "STATUS": "S", "When": time.time(), "Code": 69, "Msg": f"{self.api_str} {command}", } ], command.upper(): [{command: "test"}], "id": 1, } ).encode("utf-8") @patch("pyasic.rpc.base.BaseMinerRPCAPI._send_bytes") async def test_command_error_raises_api_error(self, mock_send_bytes): if self.api is None: return mock_send_bytes.return_value = self.get_error_value() with self.assertRaises(APIError): await self.api.send_command("summary") @patch("pyasic.rpc.base.BaseMinerRPCAPI._send_bytes") async def test_command_error_ignored_by_flag(self, mock_send_bytes): if self.api is None: return mock_send_bytes.return_value = self.get_error_value() try: await self.api.send_command( "summary", ignore_errors=True, allow_warning=False ) except APIError: self.fail( f"Expected ignore_errors flag to ignore error in {self.api_str} API" ) @patch("pyasic.rpc.base.BaseMinerRPCAPI._send_bytes") async def test_all_read_command_success(self, mock_send_bytes): if self.api is None: return commands = self.api.commands for command in commands: with self.subTest( msg=f"Test of command success on {self.api_str} API with command={command}", command=command, ): api_func = getattr(self.api, command) # For BTMiner, we need to handle multiple calls for privileged commands # Use a list to track calls and return different values if self.api_str == "BTMiner": def btminer_side_effect(data): # Parse the command from the sent data try: # data is already bytes if isinstance(data, bytes): cmd_str = data.decode("utf-8") cmd_data = json.loads(cmd_str) if "cmd" in cmd_data: sent_cmd = cmd_data["cmd"] if sent_cmd == "get_token": # Return proper token response return self.get_success_value("get_token") except Exception: # If we can't parse it, it might be encrypted privileged command pass # Default return for the actual command return self.get_success_value(command) mock_send_bytes.side_effect = btminer_side_effect else: mock_send_bytes.return_value = self.get_success_value(command) try: await api_func() except APIError: self.fail(f"Expected successful return from API function {command}") except TypeError: continue except KeyError: continue class TestBFGMinerAPI(TestAPIBase): def setUpData(self): self.api = BFGMinerRPCAPI(self.ip) self.api_str = "BFGMiner" class TestBMMinerAPI(TestAPIBase): def setUpData(self): self.api = BMMinerRPCAPI(self.ip) self.api_str = "BMMiner" class TestBOSMinerAPI(TestAPIBase): def setUpData(self): self.api = BOSMinerRPCAPI(self.ip) self.api_str = "BOSMiner" class TestBTMinerAPI(TestAPIBase): def setUpData(self): self.api = BTMinerRPCAPI(self.ip) self.api_str = "BTMiner" class TestCGMinerAPI(TestAPIBase): def setUpData(self): self.api = CGMinerRPCAPI(self.ip) self.api_str = "CGMiner" class TestGCMinerRPCAPI(TestAPIBase): def setUpData(self): self.api = GCMinerRPCAPI(self.ip) self.api_str = "GCMiner" class TestLuxOSAPI(TestAPIBase): def setUpData(self): self.api = LUXMinerRPCAPI(self.ip) self.api_str = "LuxOS" if __name__ == "__main__": unittest.main()
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/tests/network_tests/__init__.py
tests/network_tests/__init__.py
# ------------------------------------------------------------------------------ # 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. - # ------------------------------------------------------------------------------ import ipaddress import unittest from pyasic.network import MinerNetwork class NetworkTest(unittest.TestCase): def test_net_range(self): net_range_str = ["192.168.1.29", "192.168.1.40-43", "192.168.1.60"] net_range_list = [ "192.168.1.29", "192.168.1.40", "192.168.1.41", "192.168.1.42", "192.168.1.43", "192.168.1.60", ] net_1 = list(MinerNetwork.from_list(net_range_list).hosts) net_2 = list(MinerNetwork.from_list(net_range_str).hosts) correct_net = [ ipaddress.IPv4Address("192.168.1.29"), ipaddress.IPv4Address("192.168.1.40"), ipaddress.IPv4Address("192.168.1.41"), ipaddress.IPv4Address("192.168.1.42"), ipaddress.IPv4Address("192.168.1.43"), ipaddress.IPv4Address("192.168.1.60"), ] self.assertEqual(net_1, correct_net) self.assertEqual(net_2, correct_net) def test_net(self): net_1_str = "192.168.1.0" net_1_mask = "/29" net_1 = list(MinerNetwork.from_subnet(net_1_str + net_1_mask).hosts) net_2 = list(MinerNetwork.from_list(["192.168.1.1-5", "192.168.1.6"]).hosts) correct_net = [ ipaddress.IPv4Address("192.168.1.1"), ipaddress.IPv4Address("192.168.1.2"), ipaddress.IPv4Address("192.168.1.3"), ipaddress.IPv4Address("192.168.1.4"), ipaddress.IPv4Address("192.168.1.5"), ipaddress.IPv4Address("192.168.1.6"), ] self.assertEqual(net_1, correct_net) self.assertEqual(net_2, correct_net) def test_net_defaults(self): net = MinerNetwork.from_subnet("192.168.1.1/24") self.assertEqual( net.hosts, list(ipaddress.ip_network("192.168.1.0/24").hosts()) ) if __name__ == "__main__": unittest.main()
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/tests/local_tests/test_avalon_local.py
tests/local_tests/test_avalon_local.py
import argparse import os import sys import unittest from pyasic.miners.base import BaseMiner from pyasic.miners.data import DataOptions from pyasic.miners.factory import MinerFactory class TestAvalonLocal(unittest.IsolatedAsyncioTestCase): ip: str | None = None password: str | None = None miner: BaseMiner @classmethod def setUpClass(cls) -> None: cls.ip = os.getenv("AVALON_IP") cls.password = os.getenv("AVALON_PASSWORD") if not cls.ip: raise unittest.SkipTest("Set AVALON_IP to run local Avalon tests") async def asyncSetUp(self) -> None: assert self.ip is not None # set in setUpClass or test is skipped factory = MinerFactory() miner = await factory.get_miner(self.ip) # type: ignore[func-returns-value] if miner is None: self.skipTest("Miner discovery failed; check IP/auth") self.miner = miner return None # Some Avalon units do not require authentication; when needed they use the # cgminer RPC interface which pyasic handles internally. No extra setup here. async def test_get_data_basics(self): data = await self.miner.get_data( include=[ DataOptions.HOSTNAME, DataOptions.API_VERSION, DataOptions.FW_VERSION, DataOptions.HASHRATE, DataOptions.POOLS, ] ) if data.hostname is None: self.skipTest("Hostname not reported; skipping") if data.hashrate is None: self.skipTest("Hashrate not reported; skipping") self.assertIsNotNone(data.hostname) self.assertIsNotNone(data.hashrate) async def test_get_config(self): cfg = await self.miner.get_config() self.assertIsNotNone(cfg) async def test_fault_light_cycle(self): # Not all Avalon minis/nanos support fault light control; tolerate failure. if not hasattr(self.miner, "fault_light_on"): self.skipTest("Miner missing fault light support") turned_on = await self.miner.fault_light_on() turned_off = await self.miner.fault_light_off() if not (turned_on or turned_off): self.skipTest("Fault light control unsupported or disabled") self.assertTrue(True) def _main() -> None: parser = argparse.ArgumentParser(description="Local Avalon mini/nano smoke tests") parser.add_argument("ip", nargs="?", help="Miner IP (overrides AVALON_IP)") parser.add_argument("--password", help="Optional web/RPC password", default=None) args, unittest_args = parser.parse_known_args() if args.ip: os.environ["AVALON_IP"] = args.ip if args.password: os.environ["AVALON_PASSWORD"] = args.password unittest.main(argv=[sys.argv[0]] + unittest_args) if __name__ == "__main__": _main()
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/tests/local_tests/test_bitaxe_local.py
tests/local_tests/test_bitaxe_local.py
import argparse import os import sys import unittest from typing import Any from pyasic.miners.base import BaseMiner from pyasic.miners.data import DataOptions from pyasic.miners.factory import MinerFactory from pyasic.web.espminer import ESPMinerWebAPI class TestBitAxeLocal(unittest.IsolatedAsyncioTestCase): ip: str | None = None miner: BaseMiner @classmethod def setUpClass(cls) -> None: cls.ip = os.getenv("BITAXE_IP") if not cls.ip: raise unittest.SkipTest("Set BITAXE_IP to run local BitAxe tests") async def asyncSetUp(self) -> None: assert self.ip is not None # set in setUpClass or test is skipped factory = MinerFactory() miner = await factory.get_miner(self.ip) # type: ignore[func-returns-value] if miner is None: self.skipTest("Miner discovery failed; check IP") self.miner = miner return None async def test_get_data_basics(self): data = await self.miner.get_data( include=[ DataOptions.HOSTNAME, DataOptions.API_VERSION, DataOptions.FW_VERSION, DataOptions.HASHRATE, DataOptions.MAC, ] ) if data.hostname is None: self.skipTest("Hostname not reported; skipping") if data.hashrate is None: self.skipTest("Hashrate not reported; skipping") if data.mac is None: self.skipTest("MAC not reported; skipping") self.assertIsNotNone(data.hostname) self.assertIsNotNone(data.hashrate) self.assertIsNotNone(data.mac) async def test_get_config(self): cfg = await self.miner.get_config() self.assertIsNotNone(cfg) async def test_get_data_extended(self): data = await self.miner.get_data( include=[ DataOptions.HOSTNAME, DataOptions.API_VERSION, DataOptions.FW_VERSION, DataOptions.HASHRATE, DataOptions.EXPECTED_HASHRATE, DataOptions.WATTAGE, DataOptions.UPTIME, DataOptions.FANS, DataOptions.HASHBOARDS, DataOptions.MAC, ] ) if data.hostname is None: self.skipTest("Hostname not reported; skipping") if data.api_ver is None: self.skipTest("API version not reported; skipping") if data.fw_ver is None: self.skipTest("FW version not reported; skipping") if data.expected_hashrate is None: self.skipTest("Expected hashrate not reported; skipping") if data.wattage is None: self.skipTest("Wattage not reported; skipping") if data.uptime is None: self.skipTest("Uptime not reported; skipping") if data.hashboards is None or len(data.hashboards) == 0: self.skipTest("Hashboards not reported; skipping") if data.fans is None or len(data.fans) == 0: self.skipTest("Fans not reported; skipping") self.assertIsNotNone(data.hostname) self.assertIsNotNone(data.api_ver) self.assertIsNotNone(data.fw_ver) self.assertIsNotNone(data.expected_hashrate) self.assertIsNotNone(data.wattage) self.assertIsNotNone(data.uptime) self.assertGreater(len(data.hashboards), 0) self.assertGreater(len(data.fans), 0) async def test_swarm_and_asic_info(self): # Only run if the miner exposes the ESPMiner web API methods web = getattr(self.miner, "web", None) if web is None or not isinstance(web, ESPMinerWebAPI): self.skipTest("No web client available") swarm_info: dict[str, Any] | None = None asic_info: dict[str, Any] | None = None try: swarm_info = await web.swarm_info() asic_info = await web.asic_info() except Exception: self.skipTest("Web API not reachable or not supported") if not swarm_info: self.skipTest("Swarm info empty; skipping") if not asic_info: self.skipTest("ASIC info empty; skipping") # Check for a couple of expected fields if present if "asicCount" in asic_info: self.assertIsInstance(asic_info.get("asicCount"), int) if "frequency" in asic_info: self.assertIsInstance(asic_info.get("frequency"), (int, float)) def _main() -> None: parser = argparse.ArgumentParser(description="Local BitAxe smoke tests") parser.add_argument("ip", nargs="?", help="Miner IP (overrides BITAXE_IP)") args, unittest_args = parser.parse_known_args() if args.ip: os.environ["BITAXE_IP"] = args.ip unittest.main(argv=[sys.argv[0]] + unittest_args) if __name__ == "__main__": _main()
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/pyasic/__init__.py
pyasic/__init__.py
# ------------------------------------------------------------------------------ # 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. - # ------------------------------------------------------------------------------ import importlib.metadata from pyasic import settings from pyasic.config import MinerConfig from pyasic.data import MinerData from pyasic.errors import APIError, APIWarning from pyasic.miners import * from pyasic.network import MinerNetwork from pyasic.rpc import * from pyasic.ssh import * from pyasic.web import * __version__ = importlib.metadata.version("pyasic")
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/pyasic/misc/__init__.py
pyasic/misc/__init__.py
# ------------------------------------------------------------------------------ # 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 __future__ import annotations from copy import deepcopy from pyasic.errors import APIError def api_min_version(version: str): def decorator(func): # handle the inner function that the decorator is wrapping async def inner(*args, **kwargs): api_ver = args[0].api_ver if not api_ver == "0.0.0" and isinstance(api_ver, str): api_sub_versions = api_ver.split(".") api_major_ver = int(api_sub_versions[0]) api_minor_ver = int(api_sub_versions[1]) if len(api_sub_versions) > 2: api_patch_ver = int(api_sub_versions[2]) else: api_patch_ver = 0 allowed_sub_versions = version.split(".") allowed_major_ver = int(allowed_sub_versions[0]) allowed_minor_ver = int(allowed_sub_versions[1]) if len(allowed_sub_versions) > 2: allowed_patch_ver = int(allowed_sub_versions[2]) else: allowed_patch_ver = 0 if not api_major_ver >= allowed_major_ver: raise APIError( f"Miner API version v{api_major_ver}.{api_minor_ver}.{api_patch_ver}" f" is too low for {func.__name__}, required version is at least v{version}" ) if not ( api_minor_ver >= allowed_minor_ver and api_major_ver == allowed_major_ver ): raise APIError( f"Miner API version v{api_major_ver}.{api_minor_ver}.{api_patch_ver}" f" is too low for {func.__name__}, required version is at least v{version}" ) if not ( api_patch_ver >= allowed_patch_ver and api_minor_ver == allowed_minor_ver and api_major_ver == allowed_major_ver ): raise APIError( f"Miner API version v{api_major_ver}.{api_minor_ver}.{api_patch_ver} " f"is too low for {func.__name__}, required version is at least v{version}" ) return await func(*args, **kwargs) return inner return decorator def merge_dicts(a: dict, b: dict) -> dict: result = deepcopy(a) for b_key, b_val in b.items(): a_val = result.get(b_key) if isinstance(a_val, dict) and isinstance(b_val, dict): result[b_key] = merge_dicts(a_val, b_val) else: result[b_key] = deepcopy(b_val) return result def validate_command_output(data: dict) -> tuple[bool, str | None]: if "STATUS" in data.keys(): status = data["STATUS"] if isinstance(status, str): if status in ["RESTART"]: return True, None status = data if isinstance(status, list): status = status[0] if status.get("STATUS") in ["S", "I"]: return True, None else: return False, status.get("Msg", "Unknown error") else: for key in data.keys(): # make sure not to try to turn id into a dict if key == "id": continue if "STATUS" in data[key][0].keys(): if data[key][0]["STATUS"][0]["STATUS"] not in ["S", "I"]: # this is an error return False, f"{key}: " + data[key][0]["STATUS"][0]["Msg"] return True, None
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/pyasic/device/makes.py
pyasic/device/makes.py
# ------------------------------------------------------------------------------ # 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 enum import Enum class MinerMake(str, Enum): WHATSMINER = "WhatsMiner" ANTMINER = "AntMiner" AVALONMINER = "AvalonMiner" INNOSILICON = "Innosilicon" GOLDSHELL = "Goldshell" AURADINE = "Auradine" EPIC = "ePIC" BITAXE = "BitAxe" LUCKYMINER = "LuckyMiner" ICERIVER = "IceRiver" HAMMER = "Hammer" VOLCMINER = "VolcMiner" ELPHAPEX = "Elphapex" BRAIINS = "Braiins" def __str__(self): return self.value
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/pyasic/device/firmware.py
pyasic/device/firmware.py
# ------------------------------------------------------------------------------ # 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 enum import Enum class MinerFirmware(str, Enum): STOCK = "Stock" BRAIINS_OS = "BOS+" VNISH = "VNish" EPIC = "ePIC" HIVEON = "Hive" LUXOS = "LuxOS" MARATHON = "MaraFW" def __str__(self): return self.value
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/pyasic/device/models.py
pyasic/device/models.py
from enum import Enum class MinerModelType(str, Enum): pass class AntminerModels(MinerModelType): D3 = "D3" HS3 = "HS3" L3Plus = "L3+" KA3 = "KA3" KS3 = "KS3" DR5 = "DR5" KS5 = "KS5" KS5Pro = "KS5Pro" L7 = "L7" K7 = "K7" D7 = "D7" E9Pro = "E9Pro" S9 = "S9" S9i = "S9i" S9j = "S9j" T9 = "T9" D9 = "D9" L9 = "L9" Z15 = "Z15" Z15Pro = "Z15 Pro" S17 = "S17" S17Plus = "S17+" S17Pro = "S17 Pro" S17e = "S17e" T17 = "T17" T17Plus = "T17+" T17e = "T17e" S19 = "S19" S19NoPIC = "S19 No PIC" S19L = "S19L" S19Pro = "S19 Pro" S19j = "S19j" S19i = "S19i" S19Plus = "S19+" 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" S19XP = "S19 XP" S19a = "S19a" S19aPro = "S19a Pro" S19Hydro = "S19 Hydro" S19ProHydro = "S19 Pro Hydro" S19ProPlusHydro = "S19 Pro+ Hydro" S19KPro = "S19K Pro" S19kPro = "S19k Pro" S19ProA = "S19 Pro A" S19kProNoPIC = "S19k Pro No PIC" S19jXP = "S19j XP" T19 = "T19" S21 = "S21" S21Plus = "S21+" S21PlusHydro = "S21+ Hydro" S21Pro = "S21 Pro" S21Hydro = "S21 Hydro" T21 = "T21" S19XPHydro = "S19 XP Hydro" S19XPPlus = "S19 XP+" S21XP = "S21 XP" def __str__(self): return self.value class WhatsminerModels(MinerModelType): M20PV10 = "M20P V10" M20PV30 = "M20P V30" M20SPlusV30 = "M20S+ V30" M20SV10 = "M20S V10" M20SV20 = "M20S V20" M20SV30 = "M20S V30" M20V10 = "M20 V10" M21SPlusV20 = "M21S+ V20" M21SV20 = "M21S V20" M21SV60 = "M21S V60" M21SV70 = "M21S V70" M21V10 = "M21 V10" M29V10 = "M29 V10" M30KV10 = "M30K V10" M30LV10 = "M30L V10" M30SPlusPlusV10 = "M30S++ V10" M30SPlusPlusV20 = "M30S++ V20" M30SPlusPlusVE30 = "M30S++ VE30" M30SPlusPlusVE40 = "M30S++ VE40" M30SPlusPlusVE50 = "M30S++ VE50" M30SPlusPlusVF40 = "M30S++ VF40" M30SPlusPlusVG30 = "M30S++ VG30" M30SPlusPlusVG40 = "M30S++ VG40" M30SPlusPlusVG50 = "M30S++ VG50" M30SPlusPlusVH10 = "M30S++ VH10" M30SPlusPlusVH100 = "M30S++ VH100" M30SPlusPlusVH110 = "M30S++ VH110" M30SPlusPlusVH20 = "M30S++ VH20" M30SPlusPlusVH30 = "M30S++ VH30" M30SPlusPlusVH40 = "M30S++ VH40" M30SPlusPlusVH50 = "M30S++ VH50" M30SPlusPlusVH60 = "M30S++ VH60" M30SPlusPlusVH70 = "M30S++ VH70" M30SPlusPlusVH80 = "M30S++ VH80" M30SPlusPlusVH90 = "M30S++ VH90" M30SPlusPlusVI30 = "M30S++ VI30" M30SPlusPlusVJ20 = "M30S++ VJ20" M30SPlusPlusVJ30 = "M30S++ VJ30" M30SPlusPlusVJ50 = "M30S++ VJ50" M30SPlusPlusVJ60 = "M30S++ VJ60" M30SPlusPlusVJ70 = "M30S++ VJ70" M30SPlusPlusVK30 = "M30S++ VK30" M30SPlusPlusVK40 = "M30S++ VK40" M30SPlusV10 = "M30S+ V10" M30SPlusV100 = "M30S+ V100" M30SPlusV20 = "M30S+ V20" M30SPlusV30 = "M30S+ V30" M30SPlusV40 = "M30S+ V40" M30SPlusV50 = "M30S+ V50" M30SPlusV60 = "M30S+ V60" M30SPlusV70 = "M30S+ V70" M30SPlusV80 = "M30S+ V80" M30SPlusV90 = "M30S+ V90" M30SPlusVE100 = "M30S+ VE100" M30SPlusVE30 = "M30S+ VE30" M30SPlusVE40 = "M30S+ VE40" M30SPlusVE50 = "M30S+ VE50" M30SPlusVE60 = "M30S+ VE60" M30SPlusVE70 = "M30S+ VE70" M30SPlusVE80 = "M30S+ VE80" M30SPlusVE90 = "M30S+ VE90" M30SPlusVF20 = "M30S+ VF20" M30SPlusVF30 = "M30S+ VF30" M30SPlusVG20 = "M30S+ VG20" M30SPlusVG30 = "M30S+ VG30" M30SPlusVG40 = "M30S+ VG40" M30SPlusVG50 = "M30S+ VG50" M30SPlusVG60 = "M30S+ VG60" M30SPlusVH10 = "M30S+ VH10" M30SPlusVH20 = "M30S+ VH20" M30SPlusVH30 = "M30S+ VH30" M30SPlusVH40 = "M30S+ VH40" M30SPlusVH50 = "M30S+ VH50" M30SPlusVH60 = "M30S+ VH60" M30SPlusVH70 = "M30S+ VH70" M30SPlusVI30 = "M30S+ VI30" M30SPlusVJ30 = "M30S+ VJ30" M30SPlusVJ40 = "M30S+ VJ40" M30SV10 = "M30S V10" M30SV20 = "M30S V20" M30SV30 = "M30S V30" M30SV40 = "M30S V40" M30SV50 = "M30S V50" M30SV60 = "M30S V60" M30SV70 = "M30S V70" M30SV80 = "M30S V80" M30SVE10 = "M30S VE10" M30SVE20 = "M30S VE20" M30SVE30 = "M30S VE30" M30SVE40 = "M30S VE40" M30SVE50 = "M30S VE50" M30SVE60 = "M30S VE60" M30SVE70 = "M30S VE70" M30SVF10 = "M30S VF10" M30SVF20 = "M30S VF20" M30SVF30 = "M30S VF30" M30SVG10 = "M30S VG10" M30SVG20 = "M30S VG20" M30SVG30 = "M30S VG30" M30SVG40 = "M30S VG40" M30SVH10 = "M30S VH10" M30SVH20 = "M30S VH20" M30SVH30 = "M30S VH30" M30SVH40 = "M30S VH40" M30SVH50 = "M30S VH50" M30SVH60 = "M30S VH60" M30SVI20 = "M30S VI20" M30SVJ30 = "M30S VJ30" M30V10 = "M30 V10" M30V20 = "M30 V20" M31HV10 = "M31H V10" M31HV40 = "M31H V40" M31LV10 = "M31L V10" M31SPlusV10 = "M31S+ V10" M31SPlusV100 = "M31S+ V100" M31SPlusV20 = "M31S+ V20" M31SPlusV30 = "M31S+ V30" M31SPlusV40 = "M31S+ V40" M31SPlusV50 = "M31S+ V50" M31SPlusV60 = "M31S+ V60" M31SPlusV80 = "M31S+ V80" M31SPlusV90 = "M31S+ V90" M31SPlusVE10 = "M31S+ VE10" M31SPlusVE20 = "M31S+ VE20" M31SPlusVE30 = "M31S+ VE30" M31SPlusVE40 = "M31S+ VE40" M31SPlusVE50 = "M31S+ VE50" M31SPlusVE60 = "M31S+ VE60" M31SPlusVE80 = "M31S+ VE80" M31SPlusVF20 = "M31S+ VF20" M31SPlusVF30 = "M31S+ VF30" M31SPlusVG20 = "M31S+ VG20" M31SPlusVG30 = "M31S+ VG30" M31SEV10 = "M31SE V10" M31SEV20 = "M31SE V20" M31SEV30 = "M31SE V30" M31SV10 = "M31S V10" M31SV20 = "M31S V20" M31SV30 = "M31S V30" M31SV40 = "M31S V40" M31SV50 = "M31S V50" M31SV60 = "M31S V60" M31SV70 = "M31S V70" M31SV80 = "M31S V80" M31SV90 = "M31S V90" M31SVE10 = "M31S VE10" M31SVE20 = "M31S VE20" M31SVE30 = "M31S VE30" M31V10 = "M31 V10" M31V20 = "M31 V20" M32V10 = "M32 V10" M32V20 = "M32 V20" M32S = "M32S" M33SPlusPlusVG40 = "M33S++ VG40" M33SPlusPlusVH20 = "M33S++ VH20" M33SPlusPlusVH30 = "M33S++ VH30" M33SPlusVG20 = "M33S+ VG20" M33SPlusVG30 = "M33S+ VG30" M33SPlusVH20 = "M33S+ VH20" M33SPlusVH30 = "M33S+ VH30" M33SVG30 = "M33S VG30" M33V10 = "M33 V10" M33V20 = "M33 V20" M33V30 = "M33 V30" M34SPlusVE10 = "M34S+ VE10" M36SPlusPlusVH30 = "M36S++ VH30" M36SPlusVG30 = "M36S+ VG30" M36SVE10 = "M36S VE10" M39V10 = "M39 V10" M39V20 = "M39 V20" M39V30 = "M39 V30" M50SPlusPlusVK10 = "M50S++ VK10" M50SPlusPlusVK20 = "M50S++ VK20" M50SPlusPlusVK30 = "M50S++ VK30" M50SPlusPlusVK40 = "M50S++ VK40" M50SPlusPlusVK50 = "M50S++ VK50" M50SPlusPlusVK60 = "M50S++ VK60" M50SPlusPlusVL20 = "M50S++ VL20" M50SPlusPlusVL30 = "M50S++ VL30" M50SPlusPlusVL40 = "M50S++ VL40" M50SPlusPlusVL50 = "M50S++ VL50" M50SPlusPlusVL60 = "M50S++ VL60" M50SPlusVH30 = "M50S+ VH30" M50SPlusVH40 = "M50S+ VH40" M50SPlusVJ30 = "M50S+ VJ30" M50SPlusVJ40 = "M50S+ VJ40" M50SPlusVJ60 = "M50S+ VJ60" M50SPlusVK10 = "M50S+ VK10" M50SPlusVK20 = "M50S+ VK20" M50SPlusVK30 = "M50S+ VK30" M50SPlusVL10 = "M50S+ VL10" M50SPlusVL20 = "M50S+ VL20" M50SPlusVL30 = "M50S+ VL30" M50SVH10 = "M50S VH10" M50SVH20 = "M50S VH20" M50SVH30 = "M50S VH30" M50SVH40 = "M50S VH40" M50SVH50 = "M50S VH50" M50SVJ10 = "M50S VJ10" M50SVJ20 = "M50S VJ20" M50SVJ30 = "M50S VJ30" M50SVJ40 = "M50S VJ40" M50SVJ50 = "M50S VJ50" M50SVK10 = "M50S VK10" M50SVK20 = "M50S VK20" M50SVK30 = "M50S VK30" M50SVK50 = "M50S VK50" M50SVK60 = "M50S VK60" M50SVK70 = "M50S VK70" M50SVK80 = "M50S VK80" M50SVL20 = "M50S VL20" M50SVL30 = "M50S VL30" M50VE30 = "M50 VE30" M50VG30 = "M50 VG30" M50VH10 = "M50 VH10" M50VH20 = "M50 VH20" M50VH30 = "M50 VH30" M50VH40 = "M50 VH40" M50VH50 = "M50 VH50" M50VH60 = "M50 VH60" M50VH70 = "M50 VH70" M50VH80 = "M50 VH80" M50VH90 = "M50 VH90" M50VJ10 = "M50 VJ10" M50VJ20 = "M50 VJ20" M50VJ30 = "M50 VJ30" M50VJ40 = "M50 VJ40" M50VJ60 = "M50 VJ60" M50VK40 = "M50 VK40" M50VK50 = "M50 VK50" M52SPlusPlusVL10 = "M52S++ VL10" M52SVK30 = "M52S VK30" M53HVH10 = "M53H VH10" M53SPlusPlusVK10 = "M53S++ VK10" M53SPlusPlusVK20 = "M53S++ VK20" M53SPlusPlusVK30 = "M53S++ VK30" M53SPlusPlusVK50 = "M53S++ VK50" M53SPlusPlusVL10 = "M53S++ VL10" M53SPlusPlusVL30 = "M53S++ VL30" M53SPlusVJ30 = "M53S+ VJ30" M53SPlusVJ40 = "M53S+ VJ40" M53SPlusVJ50 = "M53S+ VJ50" M53SPlusVK30 = "M53S+ VK30" M53SVH20 = "M53S VH20" M53SVH30 = "M53S VH30" M53SVJ30 = "M53S VJ30" M53SVJ40 = "M53S VJ40" M53SVK30 = "M53S VK30" M53VH30 = "M53 VH30" M53VH40 = "M53 VH40" M53VH50 = "M53 VH50" M53VK30 = "M53 VK30" M53VK60 = "M53 VK60" M54SPlusPlusVK30 = "M54S++ VK30" M54SPlusPlusVL30 = "M54S++ VL30" M54SPlusPlusVL40 = "M54S++ VL40" M56SPlusPlusVK10 = "M56S++ VK10" M56SPlusPlusVK30 = "M56S++ VK30" M56SPlusPlusVK40 = "M56S++ VK40" M56SPlusPlusVK50 = "M56S++ VK50" M56SPlusVJ30 = "M56S+ VJ30" M56SPlusVK30 = "M56S+ VK30" M56SPlusVK40 = "M56S+ VK40" M56SPlusVK50 = "M56S+ VK50" M56SVH30 = "M56S VH30" M56SVJ30 = "M56S VJ30" M56SVJ40 = "M56S VJ40" M56VH30 = "M56 VH30" M59VH30 = "M59 VH30" M60SPlusPlusVL30 = "M60S++ VL30" M60SPlusPlusVL40 = "M60S++ VL40" M60SPlusVK30 = "M60S+ VK30" M60SPlusVK40 = "M60S+ VK40" M60SPlusVK50 = "M60S+ VK50" M60SPlusVK60 = "M60S+ VK60" M60SPlusVK70 = "M60S+ VK70" M60SPlusVL10 = "M60S+ VL10" M60SPlusVL30 = "M60S+ VL30" M60SPlusVL40 = "M60S+ VL40" M60SPlusVL50 = "M60S+ VL50" M60SPlusVL60 = "M60S+ VL60" M60SVK10 = "M60S VK10" M60SVK20 = "M60S VK20" M60SVK30 = "M60S VK30" M60SVK40 = "M60S VK40" M60SVL10 = "M60S VL10" M60SVL20 = "M60S VL20" M60SVL30 = "M60S VL30" M60SVL40 = "M60S VL40" M60SVL50 = "M60S VL50" M60SVL60 = "M60S VL60" M60SVL70 = "M60S VL70" M60VK10 = "M60 VK10" M60VK20 = "M60 VK20" M60VK30 = "M60 VK30" M60VK40 = "M60 VK40" M60VK6A = "M60 VK6A" M60VL10 = "M60 VL10" M60VL20 = "M60 VL20" M60VL30 = "M60 VL30" M60VL40 = "M60 VL40" M60VL50 = "M60 VL50" M61SPlusVL30 = "M61S+ VL30" M61SVL10 = "M61S VL10" M61SVL20 = "M61S VL20" M61SVL30 = "M61S VL30" M61VK10 = "M61 VK10" M61VK20 = "M61 VK20" M61VK30 = "M61 VK30" M61VK40 = "M61 VK40" M61VL10 = "M61 VL10" M61VL30 = "M61 VL30" M61VL40 = "M61 VL40" M61VL50 = "M61 VL50" M61VL60 = "M61 VL60" M62SPlusVK30 = "M62S+ VK30" M63SPlusPlusVL20 = "M63S++ VL20" M63SPlusVK30 = "M63S+ VK30" M63SPlusVL10 = "M63S+ VL10" M63SPlusVL20 = "M63S+ VL20" M63SPlusVL30 = "M63S+ VL30" M63SPlusVL50 = "M63S+ VL50" M63SVK10 = "M63S VK10" M63SVK20 = "M63S VK20" M63SVK30 = "M63S VK30" M63SVK60 = "M63S VK60" M63SVL10 = "M63S VL10" M63SVL50 = "M63S VL50" M63SVL60 = "M63S VL60" M63VK10 = "M63 VK10" M63VK20 = "M63 VK20" M63VK30 = "M63 VK30" M63VL10 = "M63 VL10" M63VL30 = "M63 VL30" M64SVL30 = "M64S VL30" M64VL30 = "M64 VL30" M64VL40 = "M64 VL40" M65SPlusVK30 = "M65S+ VK30" M65SVK20 = "M65S VK20" M65SVL60 = "M65S VL60" M66SPlusPlusVL20 = "M66S++ VL20" M66SPlusVK30 = "M66S+ VK30" M66SPlusVL10 = "M66S+ VL10" M66SPlusVL20 = "M66S+ VL20" M66SPlusVL30 = "M66S+ VL30" M66SPlusVL40 = "M66S+ VL40" M66SPlusVL60 = "M66S+ VL60" M66SVK20 = "M66S VK20" M66SVK30 = "M66S VK30" M66SVK40 = "M66S VK40" M66SVK50 = "M66S VK50" M66SVK60 = "M66S VK60" M66SVL10 = "M66S VL10" M66SVL20 = "M66S VL20" M66SVL30 = "M66S VL30" M66SVL40 = "M66S VL40" M66SVL50 = "M66S VL50" M66VK20 = "M66 VK20" M66VK30 = "M66 VK30" M66VL20 = "M66 VL20" M66VL30 = "M66 VL30" M67SVK30 = "M67S VK30" M70VM30 = "M70 VM30" def __str__(self): return self.value class AvalonminerModels(MinerModelType): Avalon721 = "Avalon 721" Avalon741 = "Avalon 741" Avalon761 = "Avalon 761" Avalon821 = "Avalon 821" Avalon841 = "Avalon 841" Avalon851 = "Avalon 851" Avalon921 = "Avalon 921" Avalon1026 = "Avalon 1026" Avalon1047 = "Avalon 1047" Avalon1066 = "Avalon 1066" Avalon1166Pro = "Avalon 1166 Pro" Avalon1126Pro = "Avalon 1126 Pro" Avalon1246 = "Avalon 1246" Avalon1566 = "Avalon 1566" AvalonNano3 = "Avalon Nano 3" AvalonNano3s = "Avalon Nano 3s" AvalonMini3 = "Avalon Mini 3" AvalonQHome = "Avalon Q Home" def __str__(self): return self.value class InnosiliconModels(MinerModelType): T3HPlus = "T3H+" A10X = "A10X" A11 = "A11" A11MX = "A11MX" def __str__(self): return self.value class GoldshellModels(MinerModelType): CK5 = "CK5" HS5 = "HS5" KD5 = "KD5" KDMax = "KD Max" KDBoxII = "KD Box II" KDBoxPro = "KD Box Pro" Byte = "Byte" MiniDoge = "Mini Doge" def __str__(self): return self.value class ePICModels(MinerModelType): BM520i = "BlockMiner 520i" BM720i = "BlockMiner 720i" eLITE1 = "BlockMiner eLITE 1.0" S19jProDual = "S19j Pro Dual" S19kProDual = "S19k Pro Dual" def __str__(self): return self.value class AuradineModels(MinerModelType): AT1500 = "AT1500" AT2860 = "AT2860" AT2880 = "AT2880" AI2500 = "AI2500" AI3680 = "AI3680" AD2500 = "AD2500" AD3500 = "AD3500" def __str__(self): return self.value class BitAxeModels(MinerModelType): BM1366 = "Ultra" BM1368 = "Supra" BM1397 = "Max" BM1370 = "Gamma" def __str__(self): return self.value class LuckyMinerModels(MinerModelType): LV07 = "LV07" LV08 = "LV08" def __str__(self): return self.value class IceRiverModels(MinerModelType): KS0 = "KS0" KS1 = "KS1" KS2 = "KS2" KS3 = "KS3" KS3L = "KS3L" KS3M = "KS3M" KS5 = "KS5" KS5L = "KS5L" KS5M = "KS5M" AL3 = "AL3" def __str__(self): return self.value class HammerModels(MinerModelType): D10 = "D10" def __str__(self): return self.value class VolcMinerModels(MinerModelType): D1 = "D1" def __str__(self): return self.value class BraiinsModels(MinerModelType): BMM100 = "BMM100" BMM101 = "BMM101" def __str__(self): return self.value class ElphapexModels(MinerModelType): DG1 = "DG1" DG1Plus = "DG1+" DG1Home = "DG1Home" def __str__(self): return self.value class MinerModel: ANTMINER = AntminerModels WHATSMINER = WhatsminerModels AVALONMINER = AvalonminerModels INNOSILICON = InnosiliconModels GOLDSHELL = GoldshellModels AURADINE = AuradineModels EPIC = ePICModels BITAXE = BitAxeModels LUCKYMINER = LuckyMinerModels ICERIVER = IceRiverModels HAMMER = HammerModels VOLCMINER = VolcMinerModels ELPHAPEX = ElphapexModels BRAIINS = BraiinsModels
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/pyasic/device/__init__.py
pyasic/device/__init__.py
from .algorithm import MinerAlgo from .firmware import MinerFirmware from .makes import MinerMake from .models import MinerModel
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/pyasic/device/algorithm/ethash.py
pyasic/device/algorithm/ethash.py
from __future__ import annotations from .base import MinerAlgoType from .hashrate import EtHashHashRate from .hashrate.unit import EtHashUnit class EtHashAlgo(MinerAlgoType): hashrate: type[EtHashHashRate] = EtHashHashRate unit: type[EtHashUnit] = EtHashUnit name = "EtHash"
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/pyasic/device/algorithm/blake256.py
pyasic/device/algorithm/blake256.py
from __future__ import annotations from .base import MinerAlgoType from .hashrate import Blake256HashRate from .hashrate.unit import Blake256Unit # make this json serializable class Blake256Algo(MinerAlgoType): hashrate: type[Blake256HashRate] = Blake256HashRate unit: type[Blake256Unit] = Blake256Unit name = "Blake256"
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/pyasic/device/algorithm/kadena.py
pyasic/device/algorithm/kadena.py
from __future__ import annotations from .base import MinerAlgoType from .hashrate import KadenaHashRate from .hashrate.unit import KadenaUnit # make this json serializable class KadenaAlgo(MinerAlgoType): hashrate: type[KadenaHashRate] = KadenaHashRate unit: type[KadenaUnit] = KadenaUnit name = "Kadena"
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/pyasic/device/algorithm/handshake.py
pyasic/device/algorithm/handshake.py
from __future__ import annotations from .base import MinerAlgoType from .hashrate import HandshakeHashRate from .hashrate.unit import HandshakeUnit # make this json serializable class HandshakeAlgo(MinerAlgoType): hashrate: type[HandshakeHashRate] = HandshakeHashRate unit: type[HandshakeUnit] = HandshakeUnit name = "Handshake"
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/pyasic/device/algorithm/equihash.py
pyasic/device/algorithm/equihash.py
from __future__ import annotations from .base import MinerAlgoType from .hashrate import EquihashHashRate from .hashrate.unit import EquihashUnit # make this json serializable class EquihashAlgo(MinerAlgoType): hashrate: type[EquihashHashRate] = EquihashHashRate unit: type[EquihashUnit] = EquihashUnit name = "Equihash"
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/pyasic/device/algorithm/zksnark.py
pyasic/device/algorithm/zksnark.py
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"
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/pyasic/device/algorithm/eaglesong.py
pyasic/device/algorithm/eaglesong.py
from __future__ import annotations from .base import MinerAlgoType from .hashrate import EaglesongHashRate from .hashrate.unit import EaglesongUnit # make this json serializable class EaglesongAlgo(MinerAlgoType): hashrate: type[EaglesongHashRate] = EaglesongHashRate unit: type[EaglesongUnit] = EaglesongUnit name = "Eaglesong"
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/pyasic/device/algorithm/x11.py
pyasic/device/algorithm/x11.py
from __future__ import annotations from .base import MinerAlgoType from .hashrate import X11HashRate from .hashrate.unit import X11Unit # make this json serializable class X11Algo(MinerAlgoType): hashrate: type[X11HashRate] = X11HashRate unit: type[X11Unit] = X11Unit name = "X11"
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/pyasic/device/algorithm/kheavyhash.py
pyasic/device/algorithm/kheavyhash.py
from __future__ import annotations from .base import MinerAlgoType from .hashrate import KHeavyHashHashRate from .hashrate.unit import KHeavyHashUnit # make this json serializable class KHeavyHashAlgo(MinerAlgoType): hashrate: type[KHeavyHashHashRate] = KHeavyHashHashRate unit: type[KHeavyHashUnit] = KHeavyHashUnit name = "KHeavyHash"
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/pyasic/device/algorithm/__init__.py
pyasic/device/algorithm/__init__.py
from .base import MinerAlgoType from .blake256 import Blake256Algo from .blockflow import BlockFlowAlgo from .eaglesong import EaglesongAlgo from .equihash import EquihashAlgo from .ethash import EtHashAlgo from .handshake import HandshakeAlgo from .hashrate import * from .hashrate.unit import * from .kadena import KadenaAlgo from .kheavyhash import KHeavyHashAlgo from .scrypt import ScryptAlgo from .sha256 import SHA256Algo from .x11 import X11Algo from .zksnark import ZkSnarkAlgo class MinerAlgo: SHA256 = SHA256Algo SCRYPT = ScryptAlgo KHEAVYHASH = KHeavyHashAlgo KADENA = KadenaAlgo HANDSHAKE = HandshakeAlgo X11 = X11Algo BLAKE256 = Blake256Algo EAGLESONG = EaglesongAlgo ETHASH = EtHashAlgo EQUIHASH = EquihashAlgo BLOCKFLOW = BlockFlowAlgo ZKSNARK = ZkSnarkAlgo
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/pyasic/device/algorithm/base.py
pyasic/device/algorithm/base.py
from __future__ import annotations from .hashrate.base import AlgoHashRateType, GenericHashrate from .hashrate.unit.base import AlgoHashRateUnitType, GenericUnit class MinerAlgoMeta(type): name: str def __str__(cls): return cls.name class MinerAlgoType(metaclass=MinerAlgoMeta): hashrate: type[AlgoHashRateType] unit: type[AlgoHashRateUnitType] class GenericAlgo(MinerAlgoType): hashrate: type[GenericHashrate] = GenericHashrate unit: type[GenericUnit] = GenericUnit name = "Generic (Unknown)"
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/pyasic/device/algorithm/sha256.py
pyasic/device/algorithm/sha256.py
from __future__ import annotations from .base import MinerAlgoType from .hashrate import SHA256HashRate from .hashrate.unit import SHA256Unit # make this json serializable class SHA256Algo(MinerAlgoType): hashrate: type[SHA256HashRate] = SHA256HashRate unit: type[SHA256Unit] = SHA256Unit name = "SHA256"
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/pyasic/device/algorithm/blockflow.py
pyasic/device/algorithm/blockflow.py
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"
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/pyasic/device/algorithm/scrypt.py
pyasic/device/algorithm/scrypt.py
from __future__ import annotations from .base import MinerAlgoType from .hashrate import ScryptHashRate from .hashrate.unit import ScryptUnit class ScryptAlgo(MinerAlgoType): hashrate: type[ScryptHashRate] = ScryptHashRate unit: type[ScryptUnit] = ScryptUnit name = "Scrypt"
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/pyasic/device/algorithm/hashrate/ethash.py
pyasic/device/algorithm/hashrate/ethash.py
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 from .unit import HashUnit class EtHashHashRate(AlgoHashRateType[EtHashUnit]): rate: float unit: EtHashUnit = HashUnit.ETHASH.default def into(self, other: EtHashUnit) -> Self: return self.__class__( rate=self.rate / (other.value / self.unit.value), unit=other )
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/pyasic/device/algorithm/hashrate/blake256.py
pyasic/device/algorithm/hashrate/blake256.py
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 from .unit import HashUnit class Blake256HashRate(AlgoHashRateType[Blake256Unit]): rate: float unit: Blake256Unit = HashUnit.BLAKE256.default def into(self, other: Blake256Unit) -> Self: return self.__class__( rate=self.rate / (other.value / self.unit.value), unit=other )
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/pyasic/device/algorithm/hashrate/kadena.py
pyasic/device/algorithm/hashrate/kadena.py
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 from .unit import HashUnit class KadenaHashRate(AlgoHashRateType[KadenaUnit]): rate: float unit: KadenaUnit = HashUnit.KADENA.default def into(self, other: KadenaUnit) -> Self: return self.__class__( rate=self.rate / (other.value / self.unit.value), unit=other )
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/pyasic/device/algorithm/hashrate/handshake.py
pyasic/device/algorithm/hashrate/handshake.py
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 from .unit import HashUnit class HandshakeHashRate(AlgoHashRateType[HandshakeUnit]): rate: float unit: HandshakeUnit = HashUnit.HANDSHAKE.default def into(self, other: HandshakeUnit) -> Self: return self.__class__( rate=self.rate / (other.value / self.unit.value), unit=other )
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/pyasic/device/algorithm/hashrate/equihash.py
pyasic/device/algorithm/hashrate/equihash.py
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 from .unit import HashUnit class EquihashHashRate(AlgoHashRateType[EquihashUnit]): rate: float unit: EquihashUnit = HashUnit.EQUIHASH.default def into(self, other: EquihashUnit) -> Self: return self.__class__( rate=self.rate / (other.value / self.unit.value), unit=other )
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/pyasic/device/algorithm/hashrate/zksnark.py
pyasic/device/algorithm/hashrate/zksnark.py
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[ZkSnarkUnit]): 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 )
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/pyasic/device/algorithm/hashrate/eaglesong.py
pyasic/device/algorithm/hashrate/eaglesong.py
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 from .unit import HashUnit class EaglesongHashRate(AlgoHashRateType[EaglesongUnit]): rate: float unit: EaglesongUnit = HashUnit.EAGLESONG.default def into(self, other: EaglesongUnit) -> Self: return self.__class__( rate=self.rate / (other.value / self.unit.value), unit=other )
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/pyasic/device/algorithm/hashrate/x11.py
pyasic/device/algorithm/hashrate/x11.py
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 from .unit import HashUnit class X11HashRate(AlgoHashRateType[X11Unit]): rate: float unit: X11Unit = HashUnit.X11.default def into(self, other: X11Unit) -> Self: return self.__class__( rate=self.rate / (other.value / self.unit.value), unit=other )
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/pyasic/device/algorithm/hashrate/kheavyhash.py
pyasic/device/algorithm/hashrate/kheavyhash.py
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 from .unit import HashUnit class KHeavyHashHashRate(AlgoHashRateType[KHeavyHashUnit]): rate: float unit: KHeavyHashUnit = HashUnit.KHEAVYHASH.default def into(self, other: KHeavyHashUnit) -> Self: return self.__class__( rate=self.rate / (other.value / self.unit.value), unit=other )
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/pyasic/device/algorithm/hashrate/__init__.py
pyasic/device/algorithm/hashrate/__init__.py
from .base import AlgoHashRateType from .blake256 import Blake256HashRate from .blockflow import BlockFlowHashRate from .eaglesong import EaglesongHashRate from .equihash import EquihashHashRate from .ethash import EtHashHashRate from .handshake import HandshakeHashRate from .kadena import KadenaHashRate from .kheavyhash import KHeavyHashHashRate from .scrypt import ScryptHashRate from .sha256 import SHA256HashRate from .x11 import X11HashRate from .zksnark import ZkSnarkHashRate class AlgoHashRate: SHA256 = SHA256HashRate SCRYPT = ScryptHashRate KHEAVYHASH = KHeavyHashHashRate KADENA = KadenaHashRate HANDSHAKE = HandshakeHashRate X11 = X11HashRate BLAKE256 = Blake256HashRate EAGLESONG = EaglesongHashRate ETHASH = EtHashHashRate EQUIHASH = EquihashHashRate BLOCKFLOW = BlockFlowHashRate ZKSNARK = ZkSnarkHashRate
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/pyasic/device/algorithm/hashrate/base.py
pyasic/device/algorithm/hashrate/base.py
from __future__ import annotations from abc import ABC, abstractmethod from typing import Generic, TypeVar from pydantic import BaseModel, field_serializer from typing_extensions import Self from .unit.base import AlgoHashRateUnitType, GenericUnit UnitType = TypeVar("UnitType", bound=AlgoHashRateUnitType) class AlgoHashRateType(BaseModel, ABC, Generic[UnitType]): unit: UnitType rate: float @field_serializer("unit") def serialize_unit(self, unit: UnitType): return unit.model_dump() @abstractmethod def into(self, other: UnitType) -> Self: pass def auto_unit(self): if 1 < self.rate // int(self.unit.H) < 1000: return self.into(self.unit.H) if 1 < self.rate // int(self.unit.MH) < 1000: return self.into(self.unit.MH) if 1 < self.rate // int(self.unit.GH) < 1000: return self.into(self.unit.GH) if 1 < self.rate // int(self.unit.TH) < 1000: return self.into(self.unit.TH) if 1 < self.rate // int(self.unit.PH) < 1000: return self.into(self.unit.PH) if 1 < self.rate // int(self.unit.EH) < 1000: return self.into(self.unit.EH) if 1 < self.rate // int(self.unit.ZH) < 1000: return self.into(self.unit.ZH) return self def __float__(self): return float(self.rate) def __int__(self): return int(self.rate) def __repr__(self): return f"{self.rate} {str(self.unit)}" def __round__(self, n: int | None = None): return round(self.rate, n) def __add__(self, other: Self | int | float) -> Self: if isinstance(other, AlgoHashRateType): 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, AlgoHashRateType): 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, AlgoHashRateType): 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, AlgoHashRateType): 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, AlgoHashRateType): return self.__class__( rate=self.rate * other.into(self.unit).rate, unit=self.unit ) return self.__class__(rate=self.rate * other, unit=self.unit) class GenericHashrate(AlgoHashRateType[GenericUnit]): rate: float = 0 unit: GenericUnit = GenericUnit.H def into(self, other: GenericUnit) -> Self: return self.__class__( rate=self.rate / (other.value / self.unit.value), unit=other )
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/pyasic/device/algorithm/hashrate/sha256.py
pyasic/device/algorithm/hashrate/sha256.py
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 from .unit import HashUnit class SHA256HashRate(AlgoHashRateType[SHA256Unit]): rate: float unit: SHA256Unit = HashUnit.SHA256.default def into(self, other: SHA256Unit) -> Self: return self.__class__( rate=self.rate / (other.value / self.unit.value), unit=other )
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/pyasic/device/algorithm/hashrate/blockflow.py
pyasic/device/algorithm/hashrate/blockflow.py
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[BlockFlowUnit]): 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 )
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/pyasic/device/algorithm/hashrate/scrypt.py
pyasic/device/algorithm/hashrate/scrypt.py
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 from .unit import HashUnit class ScryptHashRate(AlgoHashRateType[ScryptUnit]): rate: float unit: ScryptUnit = HashUnit.SCRYPT.default def into(self, other: ScryptUnit) -> Self: return self.__class__( rate=self.rate / (other.value / self.unit.value), unit=other )
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/pyasic/device/algorithm/hashrate/unit/ethash.py
pyasic/device/algorithm/hashrate/unit/ethash.py
from __future__ import annotations from .base import AlgoHashRateUnitType class EtHashUnit(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
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/pyasic/device/algorithm/hashrate/unit/blake256.py
pyasic/device/algorithm/hashrate/unit/blake256.py
from __future__ import annotations from .base import AlgoHashRateUnitType class Blake256Unit(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 = TH
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/pyasic/device/algorithm/hashrate/unit/kadena.py
pyasic/device/algorithm/hashrate/unit/kadena.py
from __future__ import annotations from .base import AlgoHashRateUnitType class KadenaUnit(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 = TH
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/pyasic/device/algorithm/hashrate/unit/handshake.py
pyasic/device/algorithm/hashrate/unit/handshake.py
from __future__ import annotations from .base import AlgoHashRateUnitType class HandshakeUnit(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 = TH
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/pyasic/device/algorithm/hashrate/unit/equihash.py
pyasic/device/algorithm/hashrate/unit/equihash.py
from __future__ import annotations from .base import AlgoHashRateUnitType class EquihashUnit(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 = KH def __str__(self): if self.value == self.H: return "Sol/s" if self.value == self.KH: return "KSol/s" if self.value == self.MH: return "MSol/s" if self.value == self.GH: return "GSol/s" if self.value == self.TH: return "TSol/s" if self.value == self.PH: return "PSol/s" if self.value == self.EH: return "ESol/s" if self.value == self.ZH: return "ZSol/s"
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/pyasic/device/algorithm/hashrate/unit/zksnark.py
pyasic/device/algorithm/hashrate/unit/zksnark.py
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
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/pyasic/device/algorithm/hashrate/unit/eaglesong.py
pyasic/device/algorithm/hashrate/unit/eaglesong.py
from __future__ import annotations from .base import AlgoHashRateUnitType class EaglesongUnit(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 = TH
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/pyasic/device/algorithm/hashrate/unit/x11.py
pyasic/device/algorithm/hashrate/unit/x11.py
from __future__ import annotations from .base import AlgoHashRateUnitType class X11Unit(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
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/pyasic/device/algorithm/hashrate/unit/kheavyhash.py
pyasic/device/algorithm/hashrate/unit/kheavyhash.py
from __future__ import annotations from .base import AlgoHashRateUnitType class KHeavyHashUnit(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 = TH
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/pyasic/device/algorithm/hashrate/unit/__init__.py
pyasic/device/algorithm/hashrate/unit/__init__.py
from .blake256 import Blake256Unit from .blockflow import BlockFlowUnit from .eaglesong import EaglesongUnit from .equihash import EquihashUnit from .ethash import EtHashUnit from .handshake import HandshakeUnit from .kadena import KadenaUnit from .kheavyhash import KHeavyHashUnit from .scrypt import ScryptUnit from .sha256 import SHA256Unit from .x11 import X11Unit from .zksnark import ZkSnarkUnit class HashUnit: SHA256 = SHA256Unit SCRYPT = ScryptUnit KHEAVYHASH = KHeavyHashUnit KADENA = KadenaUnit HANDSHAKE = HandshakeUnit X11 = X11Unit BLAKE256 = Blake256Unit EAGLESONG = EaglesongUnit ETHASH = EtHashUnit EQUIHASH = EquihashUnit BLOCKFLOW = BlockFlowUnit ZKSNARK = ZkSnarkUnit
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/pyasic/device/algorithm/hashrate/unit/base.py
pyasic/device/algorithm/hashrate/unit/base.py
from enum import IntEnum class AlgoHashRateUnitType(IntEnum): def __str__(self): if hasattr(self.__class__, "H") and self.value == self.__class__.H: return "H/s" if hasattr(self.__class__, "KH") and self.value == self.__class__.KH: return "KH/s" if hasattr(self.__class__, "MH") and self.value == self.__class__.MH: return "MH/s" if hasattr(self.__class__, "GH") and self.value == self.__class__.GH: return "GH/s" if hasattr(self.__class__, "TH") and self.value == self.__class__.TH: return "TH/s" if hasattr(self.__class__, "PH") and self.value == self.__class__.PH: return "PH/s" if hasattr(self.__class__, "EH") and self.value == self.__class__.EH: return "EH/s" if hasattr(self.__class__, "ZH") and self.value == self.__class__.ZH: return "ZH/s" return "" @classmethod def from_str(cls, value: str): if value == "H" and hasattr(cls, "H"): return cls.H elif value == "KH" and hasattr(cls, "KH"): return cls.KH elif value == "MH" and hasattr(cls, "MH"): return cls.MH elif value == "GH" and hasattr(cls, "GH"): return cls.GH elif value == "TH" and hasattr(cls, "TH"): return cls.TH elif value == "PH" and hasattr(cls, "PH"): return cls.PH elif value == "EH" and hasattr(cls, "EH"): return cls.EH elif value == "ZH" and hasattr(cls, "ZH"): return cls.ZH if hasattr(cls, "default"): return cls.default return None def __repr__(self): return str(self) def model_dump(self): return {"value": self.value, "suffix": str(self)} class GenericUnit(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 = H
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/pyasic/device/algorithm/hashrate/unit/sha256.py
pyasic/device/algorithm/hashrate/unit/sha256.py
from __future__ import annotations from .base import AlgoHashRateUnitType class SHA256Unit(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 = TH
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/pyasic/device/algorithm/hashrate/unit/blockflow.py
pyasic/device/algorithm/hashrate/unit/blockflow.py
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
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/pyasic/device/algorithm/hashrate/unit/scrypt.py
pyasic/device/algorithm/hashrate/unit/scrypt.py
from __future__ import annotations from .base import AlgoHashRateUnitType class ScryptUnit(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
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/pyasic/logger/__init__.py
pyasic/logger/__init__.py
# ------------------------------------------------------------------------------ # 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. - # ------------------------------------------------------------------------------ import logging def init_logger(): # if PyasicSettings().logfile: # logging.basicConfig( # filename="logfile.txt", # filemode="a", # format="%(pathname)s:%(lineno)d in %(funcName)s\n[%(levelname)s][%(asctime)s](%(name)s) - %(message)s", # datefmt="%x %X", # ) # else: logging.basicConfig( format="%(pathname)s:%(lineno)d in %(funcName)s\n[%(levelname)s][%(asctime)s](%(name)s) - %(message)s", datefmt="%x %X", ) _logger = logging.getLogger() # if PyasicSettings().debug: # _logger.setLevel(logging.DEBUG) # logging.getLogger("asyncssh").setLevel(logging.DEBUG) # else: _logger.setLevel(logging.WARNING) logging.getLogger("asyncssh").setLevel(logging.WARNING) return _logger logger = init_logger()
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/pyasic/errors/__init__.py
pyasic/errors/__init__.py
# ------------------------------------------------------------------------------ # 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. - # ------------------------------------------------------------------------------ class APIError(Exception): def __init__(self, *args): if args: self.message = args[0] else: self.message = None def __str__(self): if self.message: if self.message == "can't access write cmd": return f"{self.message}, please make sure your miner has been unlocked." return f"{self.message}" else: return "Incorrect API parameters." class PhaseBalancingError(Exception): def __init__(self, *args): if args: self.message = args[0] else: self.message = None def __str__(self): if self.message: return f"{self.message}" else: return "Failed to balance phase." class APIWarning(Warning): def __init__(self, *args): if args: self.message = args[0] else: self.message = None def __str__(self): if self.message: return f"{self.message}" else: return "Incorrect API parameters."
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/pyasic/settings/__init__.py
pyasic/settings/__init__.py
# ------------------------------------------------------------------------------ # 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 ssl import SSLContext from typing import Any, Optional import httpx from httpx import AsyncHTTPTransport from pydantic import BaseModel, Field class Settings(BaseModel): network_ping_retries: int = Field(default=1) network_ping_timeout: int = Field(default=3) network_scan_semaphore: int | None = Field(default=None) factory_get_retries: int = Field(default=1) factory_get_timeout: int = Field(default=3) get_data_retries: int = Field(default=1) api_function_timeout: int = Field(default=5) antminer_mining_mode_as_str: bool = Field(default=False) default_whatsminer_rpc_password: str = Field(default="admin") default_innosilicon_web_password: str = Field(default="admin") default_antminer_web_password: str = Field(default="root") default_hammer_web_password: str = Field(default="root") default_volcminer_web_password: str = Field(default="ltc@dog") default_bosminer_web_password: str = Field(default="root") default_vnish_web_password: str = Field(default="admin") default_goldshell_web_password: str = Field(default="123456789") default_auradine_web_password: str = Field(default="admin") default_epic_web_password: str = Field(default="letmein") default_hive_web_password: str = Field(default="root") default_iceriver_web_password: str = Field(default="12345678") default_elphapex_web_password: str = Field(default="root") default_mskminer_web_password: str = Field(default="root") default_antminer_ssh_password: str = Field(default="miner") default_bosminer_ssh_password: str = Field(default="root") class Config: validate_assignment = True extra = "allow" _settings = Settings() ssl_cxt = httpx.create_ssl_context() # this function returns an AsyncHTTPTransport instance to perform asynchronous HTTP requests # using those options. def transport(verify: str | bool | SSLContext = ssl_cxt): return AsyncHTTPTransport(verify=verify) def get(key: str, other: Any | None = None) -> Any: try: return getattr(_settings, key) except AttributeError: if hasattr(_settings, "__dict__") and key in _settings.__dict__: return _settings.__dict__[key] return other def update(key: str, val: Any) -> None: if hasattr(_settings, key): setattr(_settings, key, val) else: _settings.__dict__[key] = val
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/pyasic/rpc/btminer.py
pyasic/rpc/btminer.py
# ------------------------------------------------------------------------------ # 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. - # ------------------------------------------------------------------------------ import asyncio import base64 import binascii import datetime import hashlib import json import logging import re import struct import typing import warnings from collections.abc import AsyncGenerator from typing import Any, Literal, Optional import httpx from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes from passlib.handlers.md5_crypt import md5_crypt from pydantic import BaseModel, Field from pyasic import settings from pyasic.errors import APIError, APIWarning from pyasic.misc import api_min_version, validate_command_output from pyasic.rpc.base import BaseMinerRPCAPI ### IMPORTANT ### # you need to change the password of the miners using the Whatsminer # tool, then you can set them back to admin with this tool, but they # must be changed to something else and set back to admin with this # or the privileged API will not work using admin as the password. If # you change the password, you can pass that to this class as pwd, # or add it as the Whatsminer_pwd in the settings.toml file. class TokenResponse(BaseModel): salt: str time: str newsalt: str class Config: extra = "allow" class TokenData(BaseModel): host_sign: str host_passwd_md5: str timestamp: datetime.datetime = Field(default_factory=datetime.datetime.now) class BTMinerPrivilegedCommand(BaseModel): cmd: str token: str class Config: extra = "allow" class BTMinerV3Command(BaseModel): cmd: str param: Any | None = None class Config: extra = "forbid" class BTMinerV3PrivilegedCommand(BaseModel): cmd: str param: Any | None = None ts: int account: str token: str class Config: extra = "forbid" PrePowerOnMessage = ( Literal["wait for adjust temp"] | Literal["adjust complete"] | Literal["adjust continue"] ) def _crypt(word: str, salt: str) -> str: r"""Encrypts a word with a salt, using a standard salt format. Encrypts a word using a salt with the format \s*\$(\d+)\$([\w\./]*)\$. If this format is not used, a ValueError is raised. Parameters: word: The word to be encrypted. salt: The salt to encrypt the word. Returns: An MD5 hash of the word with the salt. """ # compile a standard format for the salt standard_salt = re.compile(r"\s*\$(\d+)\$([\w\./]*)\$") # check if the salt matches match = standard_salt.match(salt) # if the matching fails, the salt is incorrect if not match: raise ValueError("Salt format is not correct.") # save the matched salt in a new variable new_salt = match.group(2) # encrypt the word with the salt using md5 result = md5_crypt.hash(word, salt=new_salt) return result def _add_to_16(string: str) -> bytes: """Add null bytes to a string until the length is a multiple 16 Parameters: string: The string to lengthen to a multiple of 16 and encode. Returns: The input string as bytes with a multiple of 16 as the length. """ while len(string) % 16 != 0: string += "\0" return str.encode(string) # return bytes def parse_btminer_priviledge_data(token_data: TokenData, data: dict) -> dict: """Parses data returned from the BTMiner privileged API. Parses data from the BTMiner privileged API using the token from the API in an AES format. Parameters: token_data: The token information from self.get_token(). data: The data to parse, returned from the API. Returns: A decoded dict version of the privileged command output. """ # get the encoded data from the dict enc_data = data["enc"] # get the aes key from the token data aeskey_hex = hashlib.sha256(token_data.host_passwd_md5.encode()).hexdigest() # unhexlify the aes key aeskey = binascii.unhexlify(aeskey_hex.encode()) # create the required decryptor aes = Cipher(algorithms.AES(aeskey), modes.ECB()) decryptor = aes.decryptor() # decode the message with the decryptor ret_msg = json.loads( decryptor.update(base64.decodebytes(bytes(enc_data, encoding="utf8"))) .rstrip(b"\0") .decode("utf8") ) return ret_msg def create_privileged_cmd(token_data: TokenData, command: dict) -> bytes: """Create a privileged command to send to the BTMiner API. Creates a privileged command using the token from the API and the command as a dict of {'command': cmd}, with cmd being any command that the miner API accepts. Parameters: token_data: The token information from self.get_token(). command: The command to turn into a privileged command. Returns: The encrypted privileged command to be sent to the miner. """ logging.debug("(Create Prilileged Command) - Creating Privileged Command") # add token to command command["token"] = token_data.host_sign # encode host_passwd data and get hexdigest aeskey_hex = hashlib.sha256(token_data.host_passwd_md5.encode()).hexdigest() # unhexlify the encoded host_passwd aeskey = binascii.unhexlify(aeskey_hex.encode()) # create a new AES key aes = Cipher(algorithms.AES(aeskey), modes.ECB()) encryptor = aes.encryptor() # dump the command to json api_json_str = json.dumps(command) # encode the json command with the aes key api_json_str_enc = ( base64.encodebytes(encryptor.update(_add_to_16(api_json_str))) .decode("utf-8") .replace("\n", "") ) # label the data as being encoded data_enc = {"enc": 1, "data": api_json_str_enc} # dump the labeled data to json api_packet_str = json.dumps(data_enc) return api_packet_str.encode("utf-8") class BTMinerRPCAPI(BaseMinerRPCAPI): """An abstraction of the API for MicroBT Whatsminers, BTMiner. Each method corresponds to an API command in BMMiner. This class abstracts use of the BTMiner 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. All privileged commands for BTMiner's API require that you change the password of the miners using the Whatsminer tool, and it can be changed back to admin with this tool after. Set the new password either by passing it to the __init__ method, or changing it in settings.toml. Additionally, the API commands for the privileged API must be encoded using a token from the miner, all privileged commands do this automatically for you and will decode the output to look like a normal output from a miner API. """ def __init__(self, ip: str, port: int = 4028, api_ver: str = "0.0.0") -> None: super().__init__(ip, port, api_ver) self.pwd: str = settings.get("default_whatsminer_rpc_password", "admin") self.token: TokenData | None = None async def multicommand(self, *commands: str, allow_warning: bool = True) -> dict: """Creates and sends multiple commands as one command to the miner. Parameters: *commands: The commands to send as a multicommand to the miner. allow_warning: A boolean to supress APIWarnings. """ # make sure we can actually run each command, otherwise they will fail commands_list = self._check_commands(*commands) # standard multicommand format is "command1+command2" # commands starting with "get_" and the "status" command aren't supported, but we can fake that split_commands = [] for command in commands_list: if command.startswith("get_") or command == "status": commands_list.remove(command) # send seperately and append later split_commands.append(command) command = "+".join(commands_list) tasks = [] if len(split_commands) > 0: tasks.append( asyncio.create_task( self._send_split_multicommand( *split_commands, allow_warning=allow_warning ) ) ) tasks.append( asyncio.create_task(self.send_command(command, allow_warning=allow_warning)) ) try: all_data = await asyncio.gather(*tasks) except APIError: return {} data = {} for item in all_data: data.update(item) data["multicommand"] = True return data async def send_privileged_command( self, command: str, ignore_errors: bool = False, timeout: int = 10, **kwargs, ) -> dict: try: return await self._send_privileged_command( command=command, ignore_errors=ignore_errors, timeout=timeout, **kwargs ) except APIError as e: if not e.message == "can't access write cmd": raise # If we get here, we caught the specific error but didn't handle it raise # try: # await self.open_api() # except Exception as e: # raise APIError("Failed to open whatsminer API.") from e # return await self._send_privileged_command( # command=command, ignore_errors=ignore_errors, timeout=timeout, **kwargs # ) async def _send_privileged_command( self, command: str, ignore_errors: bool = False, timeout: int = 10, **kwargs, ) -> dict: logging.debug( f"{self} - (Send Privileged Command) - {command} " + f"with args {kwargs}" if len(kwargs) > 0 else "" ) cmd = {"cmd": command, **kwargs} token_data = await self.get_token() enc_command = create_privileged_cmd(token_data, cmd) logging.debug(f"{self} - (Send Privileged Command) - Sending") try: data = await self._send_bytes(enc_command, timeout=timeout) except (asyncio.CancelledError, asyncio.TimeoutError): if ignore_errors: return {} raise APIError("No data was returned from the API.") if not data: if ignore_errors: return {} raise APIError("No data was returned from the API.") data_dict: dict[Any, Any] = self._load_api_data(data) try: data_dict = parse_btminer_priviledge_data(token_data, data_dict) except Exception as e: logging.info(f"{str(self.ip)}: {e}") if not ignore_errors: # if it fails to validate, it is likely an error validation = validate_command_output(data_dict) if not validation[0]: raise APIError(validation[1]) # return the parsed json as a dict return data_dict async def get_token(self) -> TokenData: """Gets token information from the API. <details> <summary>Expand</summary> Returns: An encoded token and md5 password, which are used for the privileged API. </details> """ logging.debug(f"{self} - (Get Token) - Getting token") if self.token: if self.token.timestamp > datetime.datetime.now() - datetime.timedelta( minutes=30 ): return self.token # get the token data = await self.send_command("get_token") token_response = TokenResponse.model_validate(data["Msg"]) # encrypt the admin password with the salt pwd_str = _crypt(self.pwd, "$1$" + token_response.salt + "$") pwd_parts = pwd_str.split("$") # take the 4th item from the pwd split host_passwd_md5 = pwd_parts[3] # encrypt the pwd with the time and new salt tmp_str = _crypt( pwd_parts[3] + token_response.time, "$1$" + token_response.newsalt + "$" ) tmp_parts = tmp_str.split("$") # take the 4th item from the encrypted pwd split host_sign = tmp_parts[3] # set the current token self.token = TokenData( host_sign=host_sign, host_passwd_md5=host_passwd_md5, timestamp=datetime.datetime.now(), ) logging.debug(f"{self} - (Get Token) - Gathered token data: {self.token}") return self.token async def open_api(self): async with httpx.AsyncClient() as c: stage1_req = ( await c.post( "https://wmt.pyasic.org/v1/stage1", json={"ip": str(self.ip)}, follow_redirects=True, ) ).json() stage1_res = binascii.hexlify( await self._send_bytes(binascii.unhexlify(stage1_req), port=8889) ) stage2_req = ( await c.post( "https://wmt.pyasic.org/v1/stage2", json={ "ip": str(self.ip), "stage1_result": stage1_res.decode("utf-8"), }, ) ).json() for command in stage2_req: try: await self._send_bytes( binascii.unhexlify(command), timeout=3, port=8889 ) except asyncio.TimeoutError: pass return True #### PRIVILEGED COMMANDS #### # Please read the top of this file to learn # how to configure the Whatsminer API to # use these commands. async def update_pools( self, pool_1: str, worker_1: str, passwd_1: str, pool_2: str | None = None, worker_2: str | None = None, passwd_2: str | None = None, pool_3: str | None = None, worker_3: str | None = None, passwd_3: str | None = None, ) -> dict: """Update the pools of the miner using the API. <details> <summary>Expand</summary> Update the pools of the miner using the API, only works after changing the password of the miner using the Whatsminer tool. Parameters: pool_1: The URL to update pool 1 to. worker_1: The worker name for pool 1 to update to. passwd_1: The password for pool 1 to update to. pool_2: The URL to update pool 2 to. worker_2: The worker name for pool 2 to update to. passwd_2: The password for pool 2 to update to. pool_3: The URL to update pool 3 to. worker_3: The worker name for pool 3 to update to. passwd_3: The password for pool 3 to update to. Returns: A dict from the API to confirm the pools were updated. </details> """ return await self.send_privileged_command( "update_pools", pool1=pool_1, worker1=worker_1, passwd1=passwd_1, pool2=pool_2, worker2=worker_2, passwd2=passwd_2, pool3=pool_3, worker3=worker_3, passwd3=passwd_3, ) async def restart(self) -> dict: """Restart BTMiner using the API. <details> <summary>Expand</summary> Restart BTMiner using the API, only works after changing the password of the miner using the Whatsminer tool. Returns: A reply informing of the restart. </details> """ return await self.send_privileged_command("restart_btminer") async def power_off(self, respbefore: bool = True) -> dict: """Power off the miner using the API. <details> <summary>Expand</summary> Power off the miner using the API, only works after changing the password of the miner using the Whatsminer tool. Parameters: respbefore: Whether to respond before powering off. Returns: A reply informing of the status of powering off. </details> """ if respbefore: return await self.send_privileged_command("power_off", respbefore="true") return await self.send_privileged_command("power_off", respbefore="false") async def power_on(self) -> dict: """Power on the miner using the API. <details> <summary>Expand</summary> Power on the miner using the API, only works after changing the password of the miner using the Whatsminer tool. Returns: A reply informing of the status of powering on. </details> """ return await self.send_privileged_command("power_on") async def reset_led(self) -> dict: """Reset the LED on the miner using the API. <details> <summary>Expand</summary> Reset the LED on the miner using the API, only works after changing the password of the miner using the Whatsminer tool. Returns: A reply informing of the status of resetting the LED. </details> """ return await self.set_led(auto=True) async def set_led( self, auto: bool = True, color: str = "red", period: int = 60, duration: int = 20, start: int = 0, ) -> dict: """Set the LED on the miner using the API. <details> <summary>Expand</summary> Set the LED on the miner using the API, only works after changing the password of the miner using the Whatsminer tool. Parameters: auto: Whether or not to reset the LED to auto mode. color: The LED color to set, either 'red' or 'green'. period: The flash cycle in ms. duration: LED on time in the cycle in ms. start: LED on time offset in the cycle in ms. Returns: A reply informing of the status of setting the LED. </details> """ if auto: return await self.send_privileged_command("set_led", param="auto") return await self.send_privileged_command( "set_led", color=color, period=period, duration=duration, start=start ) async def set_low_power(self) -> dict: """Set low power mode on the miner using the API. <details> <summary>Expand</summary> Set low power mode on the miner using the API, only works after changing the password of the miner using the Whatsminer tool. Returns: A reply informing of the status of setting low power mode. </details> """ return await self.send_privileged_command("set_low_power") async def set_high_power(self) -> dict: """Set low power mode on the miner using the API. <details> <summary>Expand</summary> Set low power mode on the miner using the API, only works after changing the password of the miner using the Whatsminer tool. Returns: A reply informing of the status of setting low power mode. </details> """ return await self.send_privileged_command("set_high_power") async def set_normal_power(self) -> dict: """Set low power mode on the miner using the API. <details> <summary>Expand</summary> Set low power mode on the miner using the API, only works after changing the password of the miner using the Whatsminer tool. Returns: A reply informing of the status of setting low power mode. </details> """ return await self.send_privileged_command("set_normal_power") async def update_firmware(self, firmware: bytes) -> bool: """Upgrade the firmware running on the miner and using the firmware passed in bytes. <details> <summary>Expand</summary> Set the LED on the miner using the API, only works after changing the password of the miner using the Whatsminer tool. Parameters: firmware (bytes): The firmware binary data to be uploaded. Returns: A boolean indicating the success of the firmware upgrade. Raises: APIError: If the miner is not ready for firmware update. </details> """ ready = await self.send_privileged_command("upgrade_firmware") if not ready.get("Msg") == "ready": raise APIError(f"Not ready for firmware update: {self}") file_size = struct.pack("<I", len(firmware)) await self._send_bytes(file_size + firmware) return True async def reboot(self, timeout: int = 10) -> dict: """Reboot the miner using the API. <details> <summary>Expand</summary> Returns: A reply informing of the status of the reboot. </details> """ try: d = await asyncio.wait_for( self.send_privileged_command("reboot"), timeout=timeout ) except (asyncio.CancelledError, asyncio.TimeoutError): return {} else: return d async def factory_reset(self) -> dict: """Reset the miner to factory defaults. <details> <summary>Expand</summary> Returns: A reply informing of the status of the reset. </details> """ return await self.send_privileged_command("factory_reset") async def update_pwd(self, old_pwd: str, new_pwd: str) -> dict: """Update the admin user's password. <details> <summary>Expand</summary> Update the admin user's password, only works after changing the password of the miner using the Whatsminer tool. New password has a max length of 8 bytes, using letters, numbers, and underscores. Parameters: old_pwd: The old admin password. new_pwd: The new password to set. Returns: A reply informing of the status of setting the password. """ self.pwd = old_pwd # check if password length is greater than 8 bytes if len(new_pwd.encode("utf-8")) > 8: raise APIError( f"New password too long, the max length is 8. " f"Password size: {len(new_pwd.encode('utf-8'))}" ) try: data = await self.send_privileged_command( "update_pwd", old=old_pwd, new=new_pwd ) except APIError as e: raise e self.pwd = new_pwd return data async def net_config( self, ip: str | None = None, mask: str | None = None, gate: str | None = None, dns: str | None = None, host: str | None = None, dhcp: bool = True, ): if dhcp: return await self.send_privileged_command("net_config", param="dhcp") if None in [ip, mask, gate, dns, host]: raise APIError("Incorrect parameters.") return await self.send_privileged_command( "net_config", ip=ip, mask=mask, gate=gate, dns=dns, host=host ) async def set_target_freq(self, percent: int) -> dict: """Update the target frequency. <details> <summary>Expand</summary> Update the target frequency, only works after changing the password of the miner using the Whatsminer tool. The new frequency must be between -10% and 100%. Parameters: percent: The frequency % to set. Returns: A reply informing of the status of setting the frequency. </details> """ if not -100 < percent < 100: raise APIError( "Frequency % is outside of the allowed " "range. Please set a % between -100 and " "100" ) return await self.send_privileged_command( "set_target_freq", percent=str(percent) ) async def enable_fast_boot(self) -> dict: """Turn on fast boot. <details> <summary>Expand</summary> Turn on fast boot, only works after changing the password of the miner using the Whatsminer tool. Returns: A reply informing of the status of enabling fast boot. </details> """ return await self.send_privileged_command("enable_btminer_fast_boot") async def disable_fast_boot(self) -> dict: """Turn off fast boot. <details> <summary>Expand</summary> Turn off fast boot, only works after changing the password of the miner using the Whatsminer tool. Returns: A reply informing of the status of disabling fast boot. </details> """ return await self.send_privileged_command("disable_btminer_fast_boot") async def enable_web_pools(self) -> dict: """Turn on web pool updates. <details> <summary>Expand</summary> Turn on web pool updates, only works after changing the password of the miner using the Whatsminer tool. Returns: A reply informing of the status of enabling web pools. </details> """ return await self.send_privileged_command("enable_web_pools") async def disable_web_pools(self) -> dict: """Turn off web pool updates. <details> <summary>Expand</summary> Turn off web pool updates, only works after changing the password of the miner using the Whatsminer tool. Returns: A reply informing of the status of disabling web pools. </details> """ return await self.send_privileged_command("disable_web_pools") async def set_hostname(self, hostname: str) -> dict: """Set the hostname of the miner. <details> <summary>Expand</summary> Set the hostname of the miner, only works after changing the password of the miner using the Whatsminer tool. Parameters: hostname: The new hostname to use. Returns: A reply informing of the status of setting the hostname. </details> """ return await self.send_privileged_command("set_hostname", hostname=hostname) async def set_power_pct(self, percent: int) -> dict: """Set the power percentage of the miner based on current power. Used for temporary adjustment. <details> <summary>Expand</summary> Set the power percentage of the miner, only works after changing the password of the miner using the Whatsminer tool. Parameters: percent: The power percentage to set. Returns: A reply informing of the status of setting the power percentage. </details> """ if not 0 < percent < 100: raise APIError( "Power PCT % is outside of the allowed " "range. Please set a % between 0 and " "100" ) return await self.send_privileged_command("set_power_pct", percent=str(percent)) async def pre_power_on(self, complete: bool, msg: PrePowerOnMessage) -> dict: """Configure or check status of pre power on. <details> <summary>Expand</summary> Configure or check status of pre power on, only works after changing the password of the miner using the Whatsminer tool. Parameters: complete: check whether pre power on is complete. msg: the message to check. Returns: A reply informing of the status of pre power on. </details> """ if msg not in ("wait for adjust temp", "adjust complete", "adjust continue"): raise APIError( "Message is incorrect, please choose one of " '["wait for adjust temp", ' '"adjust complete", ' '"adjust continue"]' ) if complete: return await self.send_privileged_command( "pre_power_on", complete="true", msg=msg ) return await self.send_privileged_command( "pre_power_on", complete="false", msg=msg ) ### ADDED IN V2.0.5 Whatsminer API ### @api_min_version("2.0.5") async def set_power_pct_v2(self, percent: int) -> dict: """Set the power percentage of the miner based on current power. Used for temporary adjustment. Added in API v2.0.5. <details> <summary>Expand</summary> Set the power percentage of the miner, only works after changing the password of the miner using the Whatsminer tool. Parameters: percent: The power percentage to set. Returns: A reply informing of the status of setting the power percentage. </details> """ if not 0 < percent < 100: raise APIError( "Power PCT % is outside of the allowed " "range. Please set a % between 0 and " "100" ) return await self.send_privileged_command( "set_power_pct_v2", percent=str(percent) ) @api_min_version("2.0.5") async def set_temp_offset(self, temp_offset: int) -> dict: """Set the offset of miner hash board target temperature. <details> <summary>Expand</summary> Set the offset of miner hash board target temperature, only works after changing the password of the miner using the Whatsminer tool. Parameters: temp_offset: Target temperature offset. Returns: A reply informing of the status of setting temp offset. </details> """ if not -30 < temp_offset < 0: raise APIError( "Temp offset is outside of the allowed " "range. Please set a number between -30 and " "0." ) return await self.send_privileged_command( "set_temp_offset", temp_offset=temp_offset ) @api_min_version("2.0.5") async def adjust_power_limit(self, power_limit: int) -> dict: """Set the upper limit of the miner's power. Cannot be higher than the ordinary power of the machine. <details> <summary>Expand</summary> Set the upper limit of the miner's power, only works after changing the password of the miner using the Whatsminer tool. The miner will reboot after this is set. Parameters: power_limit: New power limit. Returns: A reply informing of the status of setting power limit. </details> """ return await self.send_privileged_command( "adjust_power_limit", power_limit=str(power_limit) ) @api_min_version("2.0.5") async def adjust_upfreq_speed(self, upfreq_speed: int) -> dict: """Set the upfreq speed, 0 is the normal speed, 9 is the fastest speed. <details> <summary>Expand</summary>
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
true
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/pyasic/rpc/ccminer.py
pyasic/rpc/ccminer.py
# ------------------------------------------------------------------------------ # 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.rpc.bmminer import BMMinerRPCAPI class CCMinerRPCAPI(BMMinerRPCAPI): """An abstraction of the CCMiner API. Each method corresponds to an API command in CCMiner. This class abstracts use of the CCMiner 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. """ def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.port = 8359
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/pyasic/rpc/bmminer.py
pyasic/rpc/bmminer.py
# ------------------------------------------------------------------------------ # 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.rpc.cgminer import CGMinerRPCAPI class BMMinerRPCAPI(CGMinerRPCAPI): """An abstraction of the BMMiner API. Each method corresponds to an API command in BMMiner. [BMMiner API documentation](https://github.com/jameshilliard/bmminer/blob/master/API-README) This class abstracts use of the BMMiner 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. """
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/pyasic/rpc/bfgminer.py
pyasic/rpc/bfgminer.py
# ------------------------------------------------------------------------------ # 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.rpc.cgminer import CGMinerRPCAPI class BFGMinerRPCAPI(CGMinerRPCAPI): """An abstraction of the BFGMiner API. Each method corresponds to an API command in BFGMiner. [BFGMiner API documentation](https://github.com/luke-jr/bfgminer/blob/bfgminer/README.RPC) This class abstracts use of the BFGMiner 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 procs(self) -> dict: """Get data on each processor with their details. <details> <summary>Expand</summary> Returns: Data on each processor with their details. </details> """ return await self.send_command("procs") async def devscan(self, info: str = "") -> dict: """Get data on each processor with their details. <details> <summary>Expand</summary> Parameters: info: Info to scan for device by. Returns: Data on each processor with their details. </details> """ return await self.send_command("devscan", parameters=info) async def proc(self, n: int = 0) -> dict: """Get data processor n. <details> <summary>Expand</summary> Parameters: n: The processor to get data on. Returns: Data on processor n. </details> """ return await self.send_command("proc", parameters=n) async def proccount(self) -> dict: """Get data fon all processors. <details> <summary>Expand</summary> Returns: Data on the processors connected. </details> """ return await self.send_command("proccount") async def pgarestart(self, n: int) -> dict: """Restart PGA n. <details> <summary>Expand</summary> Parameters: n: The PGA to restart. Returns: A confirmation of restarting PGA n. </details> """ return await self.send_command("pgadisable", parameters=n) async def procenable(self, n: int) -> dict: """Enable processor n. <details> <summary>Expand</summary> Parameters: n: The processor to enable. Returns: A confirmation of enabling processor n. </details> """ return await self.send_command("procenable", parameters=n) async def procdisable(self, n: int) -> dict: """Disable processor n. <details> <summary>Expand</summary> Parameters: n: The processor to disable. Returns: A confirmation of disabling processor n. </details> """ return await self.send_command("procdisable", parameters=n) async def procrestart(self, n: int) -> dict: """Restart processor n. <details> <summary>Expand</summary> Parameters: n: The processor to restart. Returns: A confirmation of restarting processor n. </details> """ return await self.send_command("procdisable", parameters=n) async def procidentify(self, n: int) -> dict: """Identify processor n. <details> <summary>Expand</summary> Parameters: n: The processor to identify. Returns: A confirmation of identifying processor n. </details> """ return await self.send_command("procidentify", parameters=n) async def procset(self, n: int, opt: str, val: int | None = None) -> dict: """Set processor option opt to val on processor n. <details> <summary>Expand</summary> Options: ``` MMQ - opt: clock val: 2 - 250 (multiple of 2) XBS - opt: clock val: 2 - 250 (multiple of 2) ``` Parameters: n: The processor to set the options on. opt: The option to set. Setting this to 'help' returns a help message. val: The value to set the option to. Returns: Confirmation of setting processor n with opt[,val]. </details> """ if val: return await self.send_command("procset", parameters=f"{n},{opt},{val}") else: return await self.send_command("procset", parameters=f"{n},{opt}")
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/pyasic/rpc/bosminer.py
pyasic/rpc/bosminer.py
# ------------------------------------------------------------------------------ # 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.rpc.base import BaseMinerRPCAPI class BOSMinerRPCAPI(BaseMinerRPCAPI): """An abstraction of the BOSMiner API. Each method corresponds to an API command in BOSMiner. [BOSMiner API documentation](https://docs.braiins.com/os/plus-en/Development/1_api.html) This class abstracts use of the BOSMiner 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 asccount(self) -> dict: """Get data on the number of ASC devices and their info. <details> <summary>Expand</summary> Returns: Data on all ASC devices. </details> """ return await self.send_command("asccount") async def asc(self, n: int) -> dict: """Get data for ASC device n. <details> <summary>Expand</summary> Parameters: n: The device to get data for. Returns: The data for ASC device n. </details> """ return await self.send_command("asc", parameters=n) async def devdetails(self) -> dict: """Get data on all devices with their static details. <details> <summary>Expand</summary> Returns: Data on all devices with their static details. </details> """ return await self.send_command("devdetails") async def devs(self) -> dict: """Get data on each PGA/ASC with their details. <details> <summary>Expand</summary> Returns: Data on each PGA/ASC with their details. </details> """ return await self.send_command("devs") async def edevs(self, old: bool = False) -> dict: """Get data on each PGA/ASC with their details, ignoring blacklisted and zombie devices. <details> <summary>Expand</summary> Parameters: old: Include zombie devices that became zombies less than 'old' seconds ago Returns: Data on each PGA/ASC with their details. </details> """ if old: return await self.send_command("edevs", parameters="old") else: return await self.send_command("edevs") async def pools(self) -> dict: """Get pool information. <details> <summary>Expand</summary> Returns: Miner pool information. </details> """ return await self.send_command("pools") async def summary(self) -> dict: """Get the status summary of the miner. <details> <summary>Expand</summary> Returns: The status summary of the miner. </details> """ return await self.send_command("summary") async def stats(self) -> dict: """Get stats of each device/pool with more than 1 getwork. <details> <summary>Expand</summary> Returns: Stats of each device/pool with more than 1 getwork. </details> """ return await self.send_command("stats") async def version(self) -> dict: """Get miner version info. <details> <summary>Expand</summary> Returns: Miner version information. </details> """ return await self.send_command("version") async def estats(self, old: bool = False) -> dict: """Get stats of each device/pool with more than 1 getwork, ignoring zombie devices. <details> <summary>Expand</summary> Parameters: old: Include zombie devices that became zombies less than 'old' seconds ago. Returns: Stats of each device/pool with more than 1 getwork, ignoring zombie devices. </details> """ if old: return await self.send_command("estats", parameters=old) else: return await self.send_command("estats") async def check(self, command: str) -> dict: """Check if the command `command` exists in BOSMiner. <details> <summary>Expand</summary> Parameters: command: The command to check. Returns: ## Information about a command: * Exists (Y/N) <- the command exists in this version * Access (Y/N) <- you have access to use the command </details> """ return await self.send_command("check", parameters=command) async def coin(self) -> dict: """Get information on the current coin. <details> <summary>Expand</summary> Returns: ## Information about the current coin being mined: * Hash Method <- the hashing algorithm * Current Block Time <- blocktime as a float, 0 means none * Current Block Hash <- the hash of the current block, blank means none * LP <- whether LP is in use on at least 1 pool * Network Difficulty: the current network difficulty </details> """ return await self.send_command("coin") async def lcd(self) -> dict: """Get a general all-in-one status summary of the miner. <details> <summary>Expand</summary> Returns: An all-in-one status summary of the miner. </details> """ return await self.send_command("lcd") async def fans(self) -> dict: """Get fan data. <details> <summary>Expand</summary> Returns: Data on the fans of the miner. </details> """ return await self.send_command("fans") async def tempctrl(self) -> dict: """Get temperature control data. <details> <summary>Expand</summary> Returns: Data about the temp control settings of the miner. </details> """ return await self.send_command("tempctrl") async def temps(self) -> dict: """Get temperature data. <details> <summary>Expand</summary> Returns: Data on the temps of the miner. </details> """ return await self.send_command("temps") async def tunerstatus(self) -> dict: """Get tuner status data <details> <summary>Expand</summary> Returns: Data on the status of autotuning. </details> """ return await self.send_command("tunerstatus") async def pause(self) -> dict: """Pause mining. <details> <summary>Expand</summary> Returns: Confirmation of pausing mining. </details> """ return await self.send_command("pause") async def resume(self) -> dict: """Resume mining. <details> <summary>Expand</summary> Returns: Confirmation of resuming mining. </details> """ return await self.send_command("resume")
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/pyasic/rpc/cgminer.py
pyasic/rpc/cgminer.py
# ------------------------------------------------------------------------------ # 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.rpc.base import BaseMinerRPCAPI class CGMinerRPCAPI(BaseMinerRPCAPI): """An abstraction of the CGMiner API. Each method corresponds to an API command in GGMiner. [CGMiner API documentation](https://github.com/ckolivas/cgminer/blob/master/API-README) This class abstracts use of the CGMiner 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 version(self) -> dict: """Get miner version info. <details> <summary>Expand</summary> Returns: Miner version information. </details> """ return await self.send_command("version") async def config(self) -> dict: """Get some basic configuration info. <details> <summary>Expand</summary> Returns: ## Some miner configuration information: * ASC Count <- the number of ASCs * PGA Count <- the number of PGAs * Pool Count <- the number of Pools * Strategy <- the current pool strategy * Log Interval <- the interval of logging * Device Code <- list of compiled device drivers * OS <- the current operating system * Failover-Only <- failover-only setting * Scan Time <- scan-time setting * Queue <- queue setting * Expiry <- expiry setting </details> """ return await self.send_command("config") async def summary(self) -> dict: """Get the status summary of the miner. <details> <summary>Expand</summary> Returns: The status summary of the miner. </details> """ return await self.send_command("summary") async def pools(self) -> dict: """Get pool information. <details> <summary>Expand</summary> Returns: Miner pool information. </details> """ return await self.send_command("pools") async def devs(self) -> dict: """Get data on each PGA/ASC with their details. <details> <summary>Expand</summary> Returns: Data on each PGA/ASC with their details. </details> """ return await self.send_command("devs") async def edevs(self, old: bool = False) -> dict: """Get data on each PGA/ASC with their details, ignoring blacklisted and zombie devices. <details> <summary>Expand</summary> Parameters: old: Include zombie devices that became zombies less than 'old' seconds ago Returns: Data on each PGA/ASC with their details. </details> """ if old: return await self.send_command("edevs", parameters=old) else: return await self.send_command("edevs") async def pga(self, n: int) -> dict: """Get data from PGA n. <details> <summary>Expand</summary> Parameters: n: The PGA number to get data from. Returns: Data on the PGA n. </details> """ return await self.send_command("pga", parameters=n) async def pgacount(self) -> dict: """Get data fon all PGAs. <details> <summary>Expand</summary> Returns: Data on the PGAs connected. </details> """ return await self.send_command("pgacount") async def switchpool(self, n: int) -> dict: """Switch pools to pool n. <details> <summary>Expand</summary> Parameters: n: The pool to switch to. Returns: A confirmation of switching to pool n. </details> """ return await self.send_command("switchpool", parameters=n) async def enablepool(self, n: int) -> dict: """Enable pool n. <details> <summary>Expand</summary> Parameters: n: The pool to enable. Returns: A confirmation of enabling pool n. </details> """ return await self.send_command("enablepool", parameters=n) async def addpool(self, url: str, username: str, password: str) -> dict: """Add a pool to the miner. <details> <summary>Expand</summary> Parameters: url: The URL of the new pool to add. username: The users username on the new pool. password: The worker password on the new pool. Returns: A confirmation of adding the pool. </details> """ return await self.send_command( "addpool", parameters=f"{url},{username},{password}" ) async def poolpriority(self, *n: int) -> dict: """Set pool priority. <details> <summary>Expand</summary> Parameters: *n: Pools in order of priority. Returns: A confirmation of setting pool priority. </details> """ pools = f"{','.join([str(item) for item in n])}" return await self.send_command("poolpriority", parameters=pools) async def poolquota(self, n: int, q: int) -> dict: """Set pool quota. <details> <summary>Expand</summary> Parameters: n: Pool number to set quota on. q: Quota to set the pool to. Returns: A confirmation of setting pool quota. </details> """ return await self.send_command("poolquota", parameters=f"{n},{q}") async def disablepool(self, n: int) -> dict: """Disable a pool. <details> <summary>Expand</summary> Parameters: n: Pool to disable. Returns: A confirmation of diabling the pool. </details> """ return await self.send_command("disablepool", parameters=n) async def removepool(self, n: int) -> dict: """Remove a pool. <details> <summary>Expand</summary> Parameters: n: Pool to remove. Returns: A confirmation of removing the pool. </details> """ return await self.send_command("removepool", parameters=n) async def save(self, filename: str | None = None) -> dict: """Save the config. <details> <summary>Expand</summary> Parameters: filename: Filename to save the config as. Returns: A confirmation of saving the config. </details> """ if filename: return await self.send_command("save", parameters=filename) else: return await self.send_command("save") async def quit(self) -> dict: """Quit CGMiner. <details> <summary>Expand</summary> Returns: A single "BYE" before CGMiner quits. </details> """ return await self.send_command("quit") async def notify(self) -> dict: """Notify the user of past errors. <details> <summary>Expand</summary> Returns: The last status and count of each devices problem(s). </details> """ return await self.send_command("notify") async def privileged(self) -> dict: """Check if you have privileged access. <details> <summary>Expand</summary> Returns: The STATUS section with an error if you have no privileged access, or success if you have privileged access. </details> """ return await self.send_command("privileged") async def pgaenable(self, n: int) -> dict: """Enable PGA n. <details> <summary>Expand</summary> Parameters: n: The PGA to enable. Returns: A confirmation of enabling PGA n. </details> """ return await self.send_command("pgaenable", parameters=n) async def pgadisable(self, n: int) -> dict: """Disable PGA n. <details> <summary>Expand</summary> Parameters: n: The PGA to disable. Returns: A confirmation of disabling PGA n. </details> """ return await self.send_command("pgadisable", parameters=n) async def pgaidentify(self, n: int) -> dict: """Identify PGA n. <details> <summary>Expand</summary> Parameters: n: The PGA to identify. Returns: A confirmation of identifying PGA n. </details> """ return await self.send_command("pgaidentify", parameters=n) async def devdetails(self) -> dict: """Get data on all devices with their static details. <details> <summary>Expand</summary> Returns: Data on all devices with their static details. </details> """ return await self.send_command("devdetails") async def restart(self) -> dict: """Restart CGMiner using the API. <details> <summary>Expand</summary> Returns: A reply informing of the restart. </details> """ return await self.send_command("restart") async def stats(self) -> dict: """Get stats of each device/pool with more than 1 getwork. <details> <summary>Expand</summary> Returns: Stats of each device/pool with more than 1 getwork. </details> """ return await self.send_command("stats") async def estats(self, old: bool = False) -> dict: """Get stats of each device/pool with more than 1 getwork, ignoring zombie devices. <details> <summary>Expand</summary> Parameters: old: Include zombie devices that became zombies less than 'old' seconds ago. Returns: Stats of each device/pool with more than 1 getwork, ignoring zombie devices. </details> """ if old: return await self.send_command("estats", parameters=old) else: return await self.send_command("estats") async def check(self, command: str) -> dict: """Check if the command command exists in CGMiner. <details> <summary>Expand</summary> Parameters: command: The command to check. Returns: ## Information about a command: * Exists (Y/N) <- the command exists in this version * Access (Y/N) <- you have access to use the command </details> """ return await self.send_command("check", parameters=command) async def failover_only(self, failover: bool) -> dict: """Set failover-only. <details> <summary>Expand</summary> Parameters: failover: What to set failover-only to. Returns: Confirmation of setting failover-only. </details> """ return await self.send_command("failover-only", parameters=failover) async def coin(self) -> dict: """Get information on the current coin. <details> <summary>Expand</summary> Returns: ## Information about the current coin being mined: * Hash Method <- the hashing algorithm * Current Block Time <- blocktime as a float, 0 means none * Current Block Hash <- the hash of the current block, blank means none * LP <- whether LP is in use on at least 1 pool * Network Difficulty: the current network difficulty </details> """ return await self.send_command("coin") async def debug(self, setting: str) -> dict: """Set a debug setting. <details> <summary>Expand</summary> Parameters: setting: Which setting to switch to. ## Options are: * Silent * Quiet * Verbose * Debug * RPCProto * PerDevice * WorkTime * Normal Returns: Data on which debug setting was enabled or disabled. </details> """ return await self.send_command("debug", parameters=setting) async def setconfig(self, name: str, n: int) -> dict: """Set config of name to value n. <details> <summary>Expand</summary> Parameters: name: The name of the config setting to set. ## Options are: * queue * scantime * expiry n: The value to set the 'name' setting to. Returns: The results of setting config of name to n. </details> """ return await self.send_command("setconfig", parameters=f"{name},{n}") async def usbstats(self) -> dict: """Get stats of all USB devices except ztex. <details> <summary>Expand</summary> Returns: The stats of all USB devices except ztex. </details> """ return await self.send_command("usbstats") async def pgaset(self, n: int, opt: str, val: int | None = None) -> dict: """Set PGA option opt to val on PGA n. <details> <summary>Expand</summary> Options: ``` MMQ - opt: clock val: 160 - 230 (multiple of 2) CMR - opt: clock val: 100 - 220 ``` Parameters: n: The PGA to set the options on. opt: The option to set. Setting this to 'help' returns a help message. val: The value to set the option to. Returns: Confirmation of setting PGA n with opt[,val]. </details> """ if val: return await self.send_command("pgaset", parameters=f"{n},{opt},{val}") else: return await self.send_command("pgaset", parameters=f"{n},{opt}") async def zero(self, which: str, summary: bool) -> dict: """Zero a device. <details> <summary>Expand</summary> Parameters: which: Which device to zero. Setting this to 'all' zeros all devices. Setting this to 'bestshare' zeros only the bestshare values for each pool and global. summary: Whether or not to show a full summary. Returns: the STATUS section with info on the zero and optional summary. </details> """ return await self.send_command("zero", parameters=f"{which},{summary}") async def hotplug(self, n: int) -> dict: """Enable hotplug. <details> <summary>Expand</summary> Parameters: n: The device number to set hotplug on. Returns: Information on hotplug status. </details> """ return await self.send_command("hotplug", parameters=n) async def asc(self, n: int) -> dict: """Get data for ASC device n. <details> <summary>Expand</summary> Parameters: n: The device to get data for. Returns: The data for ASC device n. </details> """ return await self.send_command("asc", parameters=n) async def ascenable(self, n: int) -> dict: """Enable ASC device n. <details> <summary>Expand</summary> Parameters: n: The device to enable. Returns: Confirmation of enabling ASC device n. </details> """ return await self.send_command("ascenable", parameters=n) async def ascdisable(self, n: int) -> dict: """Disable ASC device n. <details> <summary>Expand</summary> Parameters: n: The device to disable. Returns: Confirmation of disabling ASC device n. </details> """ return await self.send_command("ascdisable", parameters=n) async def ascidentify(self, n: int) -> dict: """Identify ASC device n. <details> <summary>Expand</summary> Parameters: n: The device to identify. Returns: Confirmation of identifying ASC device n. </details> """ return await self.send_command("ascidentify", parameters=n) async def asccount(self) -> dict: """Get data on the number of ASC devices and their info. <details> <summary>Expand</summary> Returns: Data on all ASC devices. </details> """ return await self.send_command("asccount") async def ascset(self, n: int, opt: str, val: int | str | None = None) -> dict: """Set ASC n option opt to value val. <details> <summary>Expand</summary> Sets an option on the ASC n to a value. Allowed options are: ``` AVA+BTB - opt: freq val: 256 - 1024 (chip frequency) BTB - opt: millivolts val: 1000 - 1400 (core voltage) MBA - opt: reset val: 0 - # of chips (reset a chip) opt: freq val: 0 - # of chips, 100 - 1400 (chip frequency) opt: ledcount val: 0 - 100 (chip count for LED) opt: ledlimit val: 0 - 200 (LED off below GH/s) opt: spidelay val: 0 - 9999 (SPI per I/O delay) opt: spireset val: i or s, 0 - 9999 (SPI regular reset) opt: spisleep val: 0 - 9999 (SPI reset sleep in ms) BMA - opt: volt val: 0 - 9 opt: clock val: 0 - 15 ``` Parameters: n: The ASC to set the options on. opt: The option to set. Setting this to 'help' returns a help message. val: The value to set the option to. Returns: Confirmation of setting option opt to value val. </details> """ if val: return await self.send_command("ascset", parameters=f"{n},{opt},{val}") else: return await self.send_command("ascset", parameters=f"{n},{opt}") async def lcd(self) -> dict: """Get a general all-in-one status summary of the miner. <details> <summary>Expand</summary> Returns: An all-in-one status summary of the miner. </details> """ return await self.send_command("lcd") async def lockstats(self) -> dict: """Write lockstats to STDERR. <details> <summary>Expand</summary> Returns: The result of writing the lock stats to STDERR. </details> """ return await self.send_command("lockstats")
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/pyasic/rpc/avalonminer.py
pyasic/rpc/avalonminer.py
# ------------------------------------------------------------------------------ # 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")
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/pyasic/rpc/unknown.py
pyasic/rpc/unknown.py
# ------------------------------------------------------------------------------ # 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.rpc.cgminer import CGMinerRPCAPI class UnknownRPCAPI(CGMinerRPCAPI): """An abstraction of an API for a miner which is unknown. This class is designed to try to be an intersection of as many miner APIs and API commands as possible (API ⋂ API), to ensure that it can be used with as many APIs as possible. """ async def switchpool(self, n: int) -> dict: # BOS has not implemented this yet, they will in the future raise NotImplementedError # return await self.send_command("switchpool", parameters=n) async def enablepool(self, n: int) -> dict: # BOS has not implemented this yet, they will in the future raise NotImplementedError # return await self.send_command("enablepool", parameters=n) async def disablepool(self, n: int) -> dict: # BOS has not implemented this yet, they will in the future raise NotImplementedError # return await self.send_command("disablepool", parameters=n) async def addpool(self, url: str, username: str, password: str) -> dict: # BOS has not implemented this yet, they will in the future raise NotImplementedError # return await self.send_command("addpool", parameters=f"{url},{username},{password}") async def removepool(self, n: int) -> dict: # BOS has not implemented this yet, they will in the future raise NotImplementedError # return await self.send_command("removepool", parameters=n)
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/pyasic/rpc/__init__.py
pyasic/rpc/__init__.py
# ------------------------------------------------------------------------------ # 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 .bfgminer import BFGMinerRPCAPI from .bmminer import BMMinerRPCAPI from .bosminer import BOSMinerRPCAPI from .btminer import BTMinerRPCAPI from .ccminer import CCMinerRPCAPI from .cgminer import CGMinerRPCAPI from .gcminer import GCMinerRPCAPI from .luxminer import LUXMinerRPCAPI from .unknown import UnknownRPCAPI
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/pyasic/rpc/base.py
pyasic/rpc/base.py
# ------------------------------------------------------------------------------ # 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. - # ------------------------------------------------------------------------------ import asyncio import ipaddress import json import logging import re import warnings from pyasic.errors import APIError, APIWarning from pyasic.misc import validate_command_output class BaseMinerRPCAPI: def __init__(self, ip: str, port: int = 4028, api_ver: str = "0.0.0") -> None: # api port, should be 4028 self.port = port # ip address of the miner self.ip = ipaddress.ip_address(ip) # api version if known self.api_ver = api_ver self.pwd: str | None = None def __new__(cls, *args, **kwargs): if cls is BaseMinerRPCAPI: raise TypeError(f"Only children of '{cls.__name__}' may be instantiated") return object.__new__(cls) def __repr__(self) -> str: return f"{self.__class__.__name__}: {str(self.ip)}" async def send_command( self, command: str, parameters: str | int | bool | None = None, ignore_errors: bool = False, allow_warning: bool = True, **kwargs, ) -> dict: """Send an API command to the miner and return the result. Parameters: command: The command to sent to the miner. parameters: Any additional parameters to be sent with the command. ignore_errors: Whether to raise APIError when the command returns an error. allow_warning: Whether to warn if the command fails. Returns: The return data from the API command parsed from JSON into a dict. """ logging.debug( f"{self} - (Send Privileged Command) - {command} " + f"with args {parameters}" if parameters else "" ) # create the command cmd = {"command": command, **kwargs} if parameters: cmd["parameter"] = parameters # send the command data = await self._send_bytes(json.dumps(cmd).encode("utf-8")) if data is None: raise APIError("No data returned from the API.") if data == b"Socket connect failed: Connection refused\n": if not ignore_errors: raise APIError(data.decode("utf-8")) return {} api_data = self._load_api_data(data) # check for if the user wants to allow errors to return validation = validate_command_output(api_data) if not validation[0]: if not ignore_errors: # validate the command succeeded raise APIError(f"{command}: {validation[1]}") if allow_warning: logging.warning( f"{self.ip}: API Command Error: {command}: {validation[1]}" ) logging.debug(f"{self} - (Send Command) - Received data.") return api_data # Privileged command handler, only used by whatsminers, defined here for consistency. async def send_privileged_command(self, *args, **kwargs) -> dict: return await self.send_command(*args, **kwargs) async def multicommand(self, *commands: str, allow_warning: bool = True) -> dict: """Creates and sends multiple commands as one command to the miner. Parameters: *commands: The commands to send as a multicommand to the miner. allow_warning: A boolean to supress APIWarnings. """ # make sure we can actually run each command, otherwise they will fail valid_commands = self._check_commands(*commands) # standard multicommand format is "command1+command2" # doesn't work for S19 which uses the backup _send_split_multicommand command = "+".join(valid_commands) try: data = await self.send_command(command, allow_warning=allow_warning) except APIError: data = await self._send_split_multicommand(*commands) data["multicommand"] = True return data async def _send_split_multicommand( self, *commands, allow_warning: bool = True ) -> dict: tasks = {} # send all commands individually for cmd in commands: tasks[cmd] = asyncio.create_task( self.send_command(cmd, allow_warning=allow_warning) ) results = await asyncio.gather( *[tasks[cmd] for cmd in tasks], return_exceptions=True ) data = {} for cmd, result in zip(tasks.keys(), results): if not isinstance(result, (APIError, Exception)): if result is None or result == {}: result = {} data[cmd] = [result] return data @property def commands(self) -> list: return self.get_commands() def get_commands(self) -> list: """Get a list of command accessible to a specific type of API on the miner. Returns: A list of all API commands that the miner supports. """ return [ func for func in # each function in self dir(self) if func not in ["commands", "open_api"] if callable(getattr(self, func)) and # no __ or _ methods not func.startswith("__") and not func.startswith("_") and # remove all functions that are in this base class func not in [ func for func in dir(BaseMinerRPCAPI) if callable(getattr(BaseMinerRPCAPI, func)) ] ] def _check_commands(self, *commands) -> list: allowed_commands = self.commands return_commands = [] for command in commands: if command in allowed_commands: return_commands.append(command) else: warnings.warn( f"""Removing incorrect command: {command} If you are sure you want to use this command please use API.send_command("{command}", ignore_errors=True) instead.""", APIWarning, ) return return_commands async def _send_bytes( self, data: bytes, *, port: int | None = None, timeout: int = 100, ) -> bytes: if port is None: port = self.port logging.debug(f"{self} - ([Hidden] Send Bytes) - Sending") try: # get reader and writer streams reader, writer = await asyncio.open_connection(str(self.ip), port) # handle OSError 121 except OSError as e: if e.errno == 121: logging.warning( f"{self} - ([Hidden] Send Bytes) - Semaphore timeout expired." ) return b"{}" # send the command try: data_task = asyncio.create_task(self._read_bytes(reader, timeout=timeout)) logging.debug(f"{self} - ([Hidden] Send Bytes) - Writing") writer.write(data) logging.debug(f"{self} - ([Hidden] Send Bytes) - Draining") await writer.drain() await data_task ret_data = data_task.result() except TimeoutError: logging.warning(f"{self} - ([Hidden] Send Bytes) - Read timeout expired.") return b"{}" # close the connection logging.debug(f"{self} - ([Hidden] Send Bytes) - Closing") writer.close() await writer.wait_closed() return ret_data async def _read_bytes(self, reader: asyncio.StreamReader, timeout: int) -> bytes: ret_data = b"" # loop to receive all the data logging.debug(f"{self} - ([Hidden] Send Bytes) - Receiving") try: ret_data = await asyncio.wait_for(reader.read(), timeout=timeout) except (asyncio.CancelledError, asyncio.TimeoutError) as e: raise e except Exception as e: logging.warning(f"{self} - ([Hidden] Send Bytes) - API Command Error {e}") return ret_data @staticmethod def _load_api_data(data: bytes) -> dict: # some json from the API returns with a null byte (\x00) on the end if data.endswith(b"\x00"): # handle the null byte str_data = data.decode("utf-8", errors="replace")[:-1] else: # no null byte str_data = data.decode("utf-8", errors="replace") # fix an error with a btminer return having an extra comma that breaks json.loads() str_data = str_data.replace(",}", "}") # fix an error with a btminer return having a newline that breaks json.loads() str_data = str_data.replace("\n", "") # fix an error with a bmminer return not having a specific comma that breaks json.loads() str_data = str_data.replace("}{", "},{") # fix an error with a bmminer return having a specific comma that breaks json.loads() str_data = str_data.replace("[,{", "[{") # fix an error with a btminer return having a missing comma. (2023-01-06 version) str_data = str_data.replace('""temp0', '","temp0') # fix an error with Avalonminers returning inf and nan str_data = str_data.replace('"inf"', "0") str_data = str_data.replace('"nan"', "0") # fix whatever this garbage from avalonminers is `,"id":1}` if str_data.startswith(","): str_data = f"{{{str_data[1:]}" # try to fix an error with overflowing the receive buffer # this can happen in cases such as bugged btminers returning arbitrary length error info with 100s of errors. if not str_data.endswith("}"): str_data = ",".join(str_data.split(",")[:-1]) + "}" # fix a really nasty bug with whatsminer API v2.0.4 where they return a list structured like a dict if re.search(r"\"error_code\":\[\".+\"\]", str_data): str_data = str_data.replace("[", "{").replace("]", "}") # parse the json try: parsed_data = json.loads(str_data) except json.decoder.JSONDecodeError as e: raise APIError(f"Decode Error {e}: {str_data}") return parsed_data
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/pyasic/rpc/marathon.py
pyasic/rpc/marathon.py
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")
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/pyasic/rpc/antminer.py
pyasic/rpc/antminer.py
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)
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/pyasic/rpc/luxminer.py
pyasic/rpc/luxminer.py
# ------------------------------------------------------------------------------ # 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 Literal from pyasic import APIError from pyasic.rpc.base import BaseMinerRPCAPI class LUXMinerRPCAPI(BaseMinerRPCAPI): """An abstraction of the LUXMiner API. Each method corresponds to an API command in LUXMiner. [LUXMiner API documentation](https://docs.firmware.luxor.tech/API/intro) This class abstracts use of the LUXMiner 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. """ def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.session_token = None async def send_privileged_command(self, command: str, *args, **kwargs) -> dict: if self.session_token is None: await self.auth() return await self.send_command( command, self.session_token, *args, **kwargs, ) async def send_command( self, command: str, *args, **kwargs, ) -> dict: if kwargs.get("parameters") is not None and len(args) == 0: return await super().send_command(command, **kwargs) return await super().send_command(command, parameters=",".join(args), **kwargs) async def auth(self) -> str | None: try: data = await self.session() if not data["SESSION"][0]["SessionID"] == "": self.session_token = data["SESSION"][0]["SessionID"] return self.session_token except APIError: pass try: data = await self.logon() self.session_token = data["SESSION"][0]["SessionID"] return self.session_token except (LookupError, APIError): pass return None async def addgroup(self, name: str, quota: int) -> dict: """Add a pool group. <details> <summary>Expand</summary> Parameters: name: The group name. quota: The group quota. Returns: Confirmation of adding a pool group. </details> """ return await self.send_command("addgroup", name, quota) async def addpool( self, url: str, user: str, pwd: str = "", group_id: str | None = None ) -> dict: """Add a pool. <details> <summary>Expand</summary> Parameters: url: The pool url. user: The pool username. pwd: The pool password. group_id: The group ID to use. Returns: Confirmation of adding a pool. </details> """ pool_data = [url, user, pwd] if group_id is not None: pool_data.append(group_id) return await self.send_command("addpool", *pool_data) async def asc(self, n: int) -> dict: """Get data for ASC device n. <details> <summary>Expand</summary> Parameters: n: The device to get data for. Returns: The data for ASC device n. </details> """ return await self.send_command("asc", n) async def asccount(self) -> dict: """Get data on the number of ASC devices and their info. <details> <summary>Expand</summary> Returns: Data on all ASC devices. </details> """ return await self.send_command("asccount") async def atm(self) -> dict: """Get data for Advanced Thermal Management (ATM) configuration. <details> <summary>Expand</summary> Returns: A dictionary containing ATM configuration data: - ATM: List containing a configuration object with: - Enabled: Boolean indicating if ATM is enabled - MaxProfile: Maximum frequency profile (e.g., "395MHz") - MinProfile: Minimum frequency profile (e.g., "145MHz") - PostRampMinutes: Minutes before ATM starts working after ramping - StartupMinutes: Minutes before ATM starts working at systm startup - TempWindow: Temperature window, before "Hot" in which ATM will change profiles - STATUS: List containing a status object with: - Code: Status code (e.g., 339) - Description: Miner version - Msg: Status message "ATM configuration values" - STATUS: Status indicator - When: Timestamp </details> """ return await self.send_command("atm") async def atmset( self, enabled: bool | None = None, startup_minutes: int | None = None, post_ramp_minutes: int | None = None, temp_window: int | None = None, min_profile: str | None = None, max_profile: str | None = None, prevent_oc: bool | None = None, ) -> dict: """Sets the ATM configuration. <details> <summary>Expand</summary> Parameters: enabled: Enable or disable ATM startup_minutes: Minimum time (minutes) before ATM starts at system startup post_ramp_minutes: Minimum time (minutes) before ATM starts after ramping temp_window: Number of degrees below "Hot" temperature where ATM begins adjusting profiles min_profile: Lowest profile to use (e.g. "145MHz", "+1", "-2"). Empty string for unbounded max_profile: Highest profile to use (e.g. "395MHz", "+1", "-2") prevent_oc: When turning off ATM, revert to default profile if in higher profile Returns: A dictionary containing status information about the ATM configuration update: - STATUS: List containing a status object with: - Code: Status code (e.g., 340) - Description: Miner version - Msg: Confirmation message "Advanced Thermal Management configuration updated" - STATUS: Status indicator - When: Timestamp </details> """ atmset_data = [] if enabled is not None: atmset_data.append(f"enabled={str(enabled).lower()}") if startup_minutes is not None: atmset_data.append(f"startup_minutes={startup_minutes}") if post_ramp_minutes is not None: atmset_data.append(f"post_ramp_minutes={post_ramp_minutes}") if temp_window is not None: atmset_data.append(f"temp_window={temp_window}") if min_profile is not None: atmset_data.append(f"min_profile={min_profile}") if max_profile is not None: atmset_data.append(f"max_profile={max_profile}") if prevent_oc is not None: atmset_data.append(f"prevent_oc={str(prevent_oc).lower()}") return await self.send_privileged_command("atmset", *atmset_data) async def check(self, command: str) -> dict: """Check if the command `command` exists in LUXMiner. <details> <summary>Expand</summary> Parameters: command: The command to check. Returns: ## Information about a command: * Exists (Y/N) <- the command exists in this version * Access (Y/N) <- you have access to use the command </details> """ return await self.send_command("check", command) async def coin(self) -> dict: """Get information on the current coin. <details> <summary>Expand</summary> Returns: ## Information about the current coin being mined: * Hash Method <- the hashing algorithm * Current Block Time <- blocktime as a float, 0 means none * Current Block Hash <- the hash of the current block, blank means none * LP <- whether LP is in use on at least 1 pool * Network Difficulty: the current network difficulty </details> """ return await self.send_command("coin") async def config(self) -> dict: """Get some basic configuration info. <details> <summary>Expand</summary> Returns: Miner configuration information. </details> """ return await self.send_command("config") async def curtail(self) -> dict: """Put the miner into sleep mode. <details> <summary>Expand</summary> Returns: A confirmation of putting the miner to sleep. </details> """ return await self.send_privileged_command("curtail", "sleep") async def sleep(self) -> dict: """Put the miner into sleep mode. <details> <summary>Expand</summary> Returns: A confirmation of putting the miner to sleep. </details> """ return await self.send_privileged_command("curtail", "sleep") async def wakeup(self) -> dict: """Wake the miner up from sleep mode. <details> <summary>Expand</summary> Returns: A confirmation of waking the miner up. </details> """ return await self.send_privileged_command("curtail", "wakeup") async def devdetails(self) -> dict: """Get data on all devices with their static details. <details> <summary>Expand</summary> Returns: Data on all devices with their static details. </details> """ return await self.send_command("devdetails") async def devs(self) -> dict: """Get data on each PGA/ASC with their details. <details> <summary>Expand</summary> Returns: Data on each PGA/ASC with their details. </details> """ return await self.send_command("devs") async def disablepool(self, n: int) -> dict: """Disable a pool. <details> <summary>Expand</summary> Parameters: n: Pool to disable. Returns: A confirmation of diabling the pool. </details> """ return await self.send_command("disablepool", n) async def edevs(self) -> dict: """Alias for devs""" return await self.devs() async def enablepool(self, n: int) -> dict: """Enable pool n. <details> <summary>Expand</summary> Parameters: n: The pool to enable. Returns: A confirmation of enabling pool n. </details> """ return await self.send_command("enablepool", n) async def estats(self) -> dict: """Alias for stats""" return await self.stats() async def fans(self) -> dict: """Get fan data. <details> <summary>Expand</summary> Returns: Data on the fans of the miner. </details> """ return await self.send_command("fans") async def fanset( self, speed: int | None = None, min_fans: int | None = None, power_off_speed: int | None = None, ) -> dict: """Set fan control. <details> <summary>Expand</summary> Parameters: speed: The fan speed to set. Use -1 to set automatically. min_fans: The minimum number of fans to use. Optional. Returns: A confirmation of setting fan control values. </details> """ fanset_data = [] if speed is not None: fanset_data.append(f"speed={speed}") if min_fans is not None: fanset_data.append(f"min_fans={min_fans}") if power_off_speed is not None: fanset_data.append(f"power_off_speed={power_off_speed}") return await self.send_privileged_command("fanset", *fanset_data) async def frequencyget(self, board_n: int, chip_n: int | None = None) -> dict: """Get frequency data for a board and chips. <details> <summary>Expand</summary> Parameters: board_n: The board number to get frequency info from. chip_n: The chip number to get frequency info from. Optional. Returns: Board and/or chip frequency values. </details> """ frequencyget_data = [str(board_n)] if chip_n is not None: frequencyget_data.append(str(chip_n)) return await self.send_command("frequencyget", *frequencyget_data) async def frequencyset(self, board_n: int, freq: int) -> dict: """Set frequency. <details> <summary>Expand</summary> Parameters: board_n: The board number to set frequency on. freq: The frequency to set. Returns: A confirmation of setting frequency values. </details> """ return await self.send_privileged_command("frequencyset", board_n, freq) async def frequencystop(self, board_n: int) -> dict: """Stop set frequency. <details> <summary>Expand</summary> Parameters: board_n: The board number to set frequency on. Returns: A confirmation of stopping frequencyset value. </details> """ return await self.send_privileged_command("frequencystop", board_n) async def groupquota(self, group_n: int, quota: int) -> dict: """Set a group's quota. <details> <summary>Expand</summary> Parameters: group_n: The group number to set quota on. quota: The quota to use. Returns: A confirmation of setting quota value. </details> """ return await self.send_command("groupquota", group_n, quota) async def groups(self) -> dict: """Get pool group data. <details> <summary>Expand</summary> Returns: Data on the pool groups on the miner. </details> """ return await self.send_command("groups") async def healthchipget(self, board_n: int, chip_n: int | None = None) -> dict: """Get chip health. <details> <summary>Expand</summary> Parameters: board_n: The board number to get chip health of. chip_n: The chip number to get chip health of. Optional. Returns: Chip health data. </details> """ healthchipget_data = [str(board_n)] if chip_n is not None: healthchipget_data.append(str(chip_n)) return await self.send_command("healthchipget", *healthchipget_data) async def healthchipset(self, board_n: int, chip_n: int | None = None) -> dict: """Select the next chip to have its health checked. <details> <summary>Expand</summary> Parameters: board_n: The board number to next get chip health of. chip_n: The chip number to next get chip health of. Optional. Returns: Confirmation of selecting the next health check chip. </details> """ healthchipset_data = [str(board_n)] if chip_n is not None: healthchipset_data.append(str(chip_n)) return await self.send_privileged_command("healthchipset", *healthchipset_data) async def healthctrl(self) -> dict: """Get health check config. <details> <summary>Expand</summary> Returns: Health check config. </details> """ return await self.send_command("healthctrl") async def healthctrlset(self, num_readings: int, amplified_factor: float) -> dict: """Set health control config. <details> <summary>Expand</summary> Parameters: num_readings: The minimum number of readings for evaluation. amplified_factor: Performance factor of the evaluation. Returns: A confirmation of setting health control config. </details> """ return await self.send_privileged_command( "healthctrlset", num_readings, amplified_factor ) async def kill(self) -> dict: """Forced session kill. Use logoff instead. <details> <summary>Expand</summary> Returns: A confirmation of killing the active session. </details> """ return await self.send_command("kill") async def lcd(self) -> dict: """Get a general all-in-one status summary of the miner. Always zeros on LUXMiner. <details> <summary>Expand</summary> Returns: An all-in-one status summary of the miner. </details> """ return await self.send_command("lcd") async def ledset( self, color: Literal["red"], state: Literal["on", "off", "blink"], ) -> dict: """Set led. <details> <summary>Expand</summary> Parameters: color: The color LED to set. Can be "red". state: The state to set the LED to. Can be "on", "off", or "blink". Returns: A confirmation of setting LED. </details> """ return await self.send_privileged_command("ledset", color, state) async def limits(self) -> dict: """Get max and min values of config parameters. <details> <summary>Expand</summary> Returns: Data on max and min values of config parameters. </details> """ return await self.send_command("limits") async def logoff(self) -> dict: """Log off of a session. <details> <summary>Expand</summary> Returns: Confirmation of logging off a session. </details> """ res = await self.send_privileged_command("logoff") self.session_token = None return res async def logon(self) -> dict: """Get or create a session. <details> <summary>Expand</summary> Returns: The Session ID to be used. </details> """ return await self.send_command("logon") async def pools(self) -> dict: """Get pool information. <details> <summary>Expand</summary> Returns: Miner pool information. </details> """ return await self.send_command("pools") async def power(self) -> dict: """Get the estimated power usage in watts. <details> <summary>Expand</summary> Returns: Estimated power usage in watts. </details> """ return await self.send_command("power") async def profiles(self) -> dict: """Get the available profiles. <details> <summary>Expand</summary> Returns: Data on available profiles. </details> """ return await self.send_command("profiles") async def profileset(self, profile: str) -> dict: """Set active profile for the system. <details> <summary>Expand</summary> Parameters: profile: The profile name to use. Returns: A confirmation of setting the profile. </details> """ return await self.send_privileged_command("profileset", profile) async def reboot(self, board_n: int, delay_s: int | None = None) -> dict: """Reboot a board. <details> <summary>Expand</summary> Parameters: board_n: The board to reboot. delay_s: The number of seconds to delay until startup. If it is 0, the board will just stop. Optional. Returns: A confirmation of rebooting board_n. </details> """ reboot_data = [str(board_n)] if delay_s is not None: reboot_data.append(str(delay_s)) return await self.send_privileged_command("reboot", *reboot_data) async def rebootdevice(self) -> dict: """Reboot the miner. <details> <summary>Expand</summary> Returns: A confirmation of rebooting the miner. </details> """ return await self.send_privileged_command("rebootdevice") async def removegroup(self, group_id: str) -> dict: """Remove a pool group. <details> <summary>Expand</summary> Parameters: group_id: Group id to remove. Returns: A confirmation of removing the pool group. </details> """ return await self.send_command("removegroup", parameters=group_id) async def resetminer(self) -> dict: """Restart the mining process. <details> <summary>Expand</summary> Returns: A confirmation of restarting the mining process. </details> """ return await self.send_privileged_command("resetminer") async def removepool(self, pool_id: int) -> dict: """Remove a pool. <details> <summary>Expand</summary> Parameters: pool_id: Pool to remove. Returns: A confirmation of removing the pool. </details> """ return await self.send_command("removepool", parameters=str(pool_id)) async def session(self) -> dict: """Get the current session. <details> <summary>Expand</summary> Returns: Data on the current session. </details> """ return await self.send_command("session") async def tempctrlset( self, target: int | None = None, hot: int | None = None, dangerous: int | None = None, ) -> dict: """Set temp control values. <details> <summary>Expand</summary> Parameters: target: Target temp. hot: Hot temp. dangerous: Dangerous temp. Returns: A confirmation of setting the temp control config. </details> """ return await self.send_command( "tempctrlset", target or "", hot or "", dangerous or "" ) async def stats(self) -> dict: """Get stats of each device/pool with more than 1 getwork. <details> <summary>Expand</summary> Returns: Stats of each device/pool with more than 1 getwork. </details> """ return await self.send_command("stats") async def summary(self) -> dict: """Get the status summary of the miner. <details> <summary>Expand</summary> Returns: The status summary of the miner. </details> """ return await self.send_command("summary") async def switchpool(self, pool_id: int) -> dict: """Switch to a pool. <details> <summary>Expand</summary> Parameters: pool_id: Pool to switch to. Returns: A confirmation of switching to the pool. </details> """ return await self.send_command("switchpool", pool_id) async def tempctrl(self) -> dict: """Get temperature control data. <details> <summary>Expand</summary> Returns: Data about the temp control settings of the miner. </details> """ return await self.send_command("tempctrl") async def temps(self) -> dict: """Get temperature data. <details> <summary>Expand</summary> Returns: Data on the temps of the miner. </details> """ return await self.send_command("temps") async def version(self) -> dict: """Get miner version info. <details> <summary>Expand</summary> Returns: Miner version information. </details> """ return await self.send_command("version") async def voltageget(self, board_n: int) -> dict: """Get voltage data for a board. <details> <summary>Expand</summary> Parameters: board_n: The board number to get voltage info from. Returns: Board voltage values. </details> """ return await self.send_command("frequencyget", board_n) async def voltageset(self, board_n: int, voltage: float) -> dict: """Set voltage values. <details> <summary>Expand</summary> Parameters: board_n: The board to set the voltage on. voltage: The voltage to use. Returns: A confirmation of setting the voltage. </details> """ return await self.send_privileged_command("voltageset", board_n, voltage) async def updaterun(self) -> dict: """ Send the 'updaterun' command to the miner. Returns: The response from the miner after sending the 'updaterun' command. """ return await self.send_command("updaterun")
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/pyasic/rpc/gcminer.py
pyasic/rpc/gcminer.py
# ------------------------------------------------------------------------------ # 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.rpc.base import BaseMinerRPCAPI class GCMinerRPCAPI(BaseMinerRPCAPI): """An abstraction of the GCMiner API. Each method corresponds to an API command in GCMiner. No documentation for this API is currently publicly available. This class abstracts use of the GCMiner 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 asc(self, n: int) -> dict: """Get data for ASC device n. <details> <summary>Expand</summary> Parameters: n: The device to get data for. Returns: The data for ASC device n. </details> """ return await self.send_command("asc", parameters=n) async def asccount(self) -> dict: """Get data on the number of ASC devices and their info. <details> <summary>Expand</summary> Returns: Data on all ASC devices. </details> """ return await self.send_command("asccount") async def check(self, command: str) -> dict: """Check if the command `command` exists in LUXMiner. <details> <summary>Expand</summary> Parameters: command: The command to check. Returns: ## Information about a command: * Exists (Y/N) <- the command exists in this version * Access (Y/N) <- you have access to use the command </details> """ return await self.send_command("check", parameters=command) async def coin(self) -> dict: """Get information on the current coin. <details> <summary>Expand</summary> Returns: ## Information about the current coin being mined: * Hash Method <- the hashing algorithm * Current Block Time <- blocktime as a float, 0 means none * Current Block Hash <- the hash of the current block, blank means none * LP <- whether LP is in use on at least 1 pool * Network Difficulty: the current network difficulty </details> """ return await self.send_command("coin") async def config(self) -> dict: """Get some basic configuration info. <details> <summary>Expand</summary> Returns: Miner configuration information. </details> """ return await self.send_command("config") async def devdetails(self) -> dict: """Get data on all devices with their static details. <details> <summary>Expand</summary> Returns: Data on all devices with their static details. </details> """ return await self.send_command("devdetails") async def devs(self) -> dict: """Get data on each PGA/ASC with their details. <details> <summary>Expand</summary> Returns: Data on each PGA/ASC with their details. </details> """ return await self.send_command("devs") async def edevs(self) -> dict: """Alias for devs""" return await self.send_command("edevs") async def pools(self) -> dict: """Get pool information. <details> <summary>Expand</summary> Returns: Miner pool information. </details> """ return await self.send_command("pools") async def stats(self) -> dict: """Get stats of each device/pool with more than 1 getwork. <details> <summary>Expand</summary> Returns: Stats of each device/pool with more than 1 getwork. </details> """ return await self.send_command("stats") async def estats(self) -> dict: """Alias for stats""" return await self.send_command("estats") async def summary(self) -> dict: """Get the status summary of the miner. <details> <summary>Expand</summary> Returns: The status summary of the miner. </details> """ return await self.send_command("summary") async def version(self) -> dict: """Get miner version info. <details> <summary>Expand</summary> Returns: Miner version information. </details> """ return await self.send_command("version")
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/pyasic/miners/factory.py
pyasic/miners/factory.py
# ------------------------------------------------------------------------------ # 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 __future__ import annotations import asyncio import enum import ipaddress import json import re import warnings from collections.abc import AsyncGenerator, Callable from typing import Any, cast import anyio import httpx from pyasic import settings from pyasic.logger import logger from pyasic.miners.antminer import * from pyasic.miners.auradine import * from pyasic.miners.avalonminer import * from pyasic.miners.backends import * from pyasic.miners.base import AnyMiner from pyasic.miners.bitaxe import * from pyasic.miners.blockminer import * from pyasic.miners.braiins import * from pyasic.miners.device.makes import * 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 * from pyasic.miners.whatsminer import * class MinerTypes(enum.Enum): ANTMINER = 0 WHATSMINER = 1 AVALONMINER = 2 INNOSILICON = 3 GOLDSHELL = 4 BRAIINS_OS = 5 VNISH = 6 HIVEON = 7 LUX_OS = 8 EPIC = 9 AURADINE = 10 MARATHON = 11 BITAXE = 12 ICERIVER = 13 HAMMER = 14 VOLCMINER = 15 LUCKYMINER = 16 ELPHAPEX = 17 MSKMINER = 18 MINER_CLASSES: dict[MinerTypes, dict[str | None, Any]] = { MinerTypes.ANTMINER: { None: type("AntminerUnknown", (BMMiner, AntMinerMake), {}), "ANTMINER D3": CGMinerD3, "ANTMINER HS3": BMMinerHS3, "ANTMINER L3+": BMMinerL3Plus, "ANTMINER KA3": BMMinerKA3, "ANTMINER KS3": BMMinerKS3, "ANTMINER DR5": CGMinerDR5, "ANTMINER KS5": BMMinerKS5, "ANTMINER KS5 PRO": BMMinerKS5Pro, "ANTMINER L7": BMMinerL7, "ANTMINER L7_I": BMMinerL7, "ANTMINER K7": BMMinerK7, "ANTMINER D7": BMMinerD7, "ANTMINER E9 PRO": BMMinerE9Pro, "ANTMINER D9": BMMinerD9, "ANTMINER S9": BMMinerS9, "ANTMINER S9I": BMMinerS9i, "ANTMINER S9J": BMMinerS9j, "ANTMINER T9": BMMinerT9, "ANTMINER L9": BMMinerL9, "ANTMINER L9_I": BMMinerL9, "ANTMINER Z15": CGMinerZ15, "ANTMINER Z15 PRO": BMMinerZ15Pro, "ANTMINER S17": BMMinerS17, "ANTMINER S17+": BMMinerS17Plus, "ANTMINER S17 PRO": BMMinerS17Pro, "ANTMINER S17E": BMMinerS17e, "ANTMINER T17": BMMinerT17, "ANTMINER T17+": BMMinerT17Plus, "ANTMINER T17E": BMMinerT17e, "ANTMINER S19": BMMinerS19, "ANTMINER S19L": BMMinerS19L, "ANTMINER S19 PRO": BMMinerS19Pro, "ANTMINER S19J": BMMinerS19j, "ANTMINER S19I": BMMinerS19i, "ANTMINER S19+": BMMinerS19Plus, "ANTMINER S19J88NOPIC": BMMinerS19jNoPIC, "ANTMINER S19PRO+": BMMinerS19ProPlus, "ANTMINER S19J PRO": BMMinerS19jPro, "ANTMINER S19J+": BMMinerS19jPlus, "ANTMINER S19J PRO+": BMMinerS19jProPlus, "BHB42XXXX": BMMinerS19jProPlus, "ANTMINER S19 XP": BMMinerS19XP, "ANTMINER S19A": BMMinerS19a, "ANTMINER S19A PRO": BMMinerS19aPro, "ANTMINER S19 HYDRO": BMMinerS19Hydro, "ANTMINER S19 PRO HYD.": BMMinerS19ProHydro, "ANTMINER S19 PRO+ HYD.": BMMinerS19ProPlusHydro, "ANTMINER S19K PRO": BMMinerS19KPro, "ANTMINER S19J XP": BMMinerS19jXP, "ANTMINER T19": BMMinerT19, "ANTMINER S21": BMMinerS21, "ANTMINER BHB68601": BMMinerS21, # ??? "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, "ANTMINER S21 XP": BMMinerS21XP, }, MinerTypes.WHATSMINER: { None: type("WhatsminerUnknown", (BTMiner, WhatsMinerMake), {}), "M20PV10": BTMinerM20PV10, "M20PV30": BTMinerM20PV30, "M20S+V30": BTMinerM20SPlusV30, "M20SV10": BTMinerM20SV10, "M20SV20": BTMinerM20SV20, "M20SV30": BTMinerM20SV30, "M20V10": BTMinerM20V10, "M21S+V20": BTMinerM21SPlusV20, "M21SV20": BTMinerM21SV20, "M21SV60": BTMinerM21SV60, "M21SV70": BTMinerM21SV70, "M21V10": BTMinerM21V10, "M29V10": BTMinerM29V10, "M30KV10": BTMinerM30KV10, "M30LV10": BTMinerM30LV10, "M30S++V10": BTMinerM30SPlusPlusV10, "M30S++V20": BTMinerM30SPlusPlusV20, "M30S++VE30": BTMinerM30SPlusPlusVE30, "M30S++VE40": BTMinerM30SPlusPlusVE40, "M30S++VE50": BTMinerM30SPlusPlusVE50, "M30S++VF40": BTMinerM30SPlusPlusVF40, "M30S++VG30": BTMinerM30SPlusPlusVG30, "M30S++VG40": BTMinerM30SPlusPlusVG40, "M30S++VG50": BTMinerM30SPlusPlusVG50, "M30S++VH10": BTMinerM30SPlusPlusVH10, "M30S++VH100": BTMinerM30SPlusPlusVH100, "M30S++VH110": BTMinerM30SPlusPlusVH110, "M30S++VH20": BTMinerM30SPlusPlusVH20, "M30S++VH30": BTMinerM30SPlusPlusVH30, "M30S++VH40": BTMinerM30SPlusPlusVH40, "M30S++VH50": BTMinerM30SPlusPlusVH50, "M30S++VH60": BTMinerM30SPlusPlusVH60, "M30S++VH70": BTMinerM30SPlusPlusVH70, "M30S++VH80": BTMinerM30SPlusPlusVH80, "M30S++VH90": BTMinerM30SPlusPlusVH90, "M30S++VI30": BTMinerM30SPlusPlusVI30, "M30S++VJ20": BTMinerM30SPlusPlusVJ20, "M30S++VJ30": BTMinerM30SPlusPlusVJ30, "M30S++VJ50": BTMinerM30SPlusPlusVJ50, "M30S++VJ60": BTMinerM30SPlusPlusVJ60, "M30S++VJ70": BTMinerM30SPlusPlusVJ70, "M30S++VK30": BTMinerM30SPlusPlusVK30, "M30S++VK40": BTMinerM30SPlusPlusVK40, "M30S+V10": BTMinerM30SPlusV10, "M30S+V100": BTMinerM30SPlusV100, "M30S+V20": BTMinerM30SPlusV20, "M30S+V30": BTMinerM30SPlusV30, "M30S+V40": BTMinerM30SPlusV40, "M30S+V50": BTMinerM30SPlusV50, "M30S+V60": BTMinerM30SPlusV60, "M30S+V70": BTMinerM30SPlusV70, "M30S+V80": BTMinerM30SPlusV80, "M30S+V90": BTMinerM30SPlusV90, "M30S+VE100": BTMinerM30SPlusVE100, "M30S+VE30": BTMinerM30SPlusVE30, "M30S+VE40": BTMinerM30SPlusVE40, "M30S+VE50": BTMinerM30SPlusVE50, "M30S+VE60": BTMinerM30SPlusVE60, "M30S+VE70": BTMinerM30SPlusVE70, "M30S+VE80": BTMinerM30SPlusVE80, "M30S+VE90": BTMinerM30SPlusVE90, "M30S+VF20": BTMinerM30SPlusVF20, "M30S+VF30": BTMinerM30SPlusVF30, "M30S+VG20": BTMinerM30SPlusVG20, "M30S+VG30": BTMinerM30SPlusVG30, "M30S+VG40": BTMinerM30SPlusVG40, "M30S+VG50": BTMinerM30SPlusVG50, "M30S+VG60": BTMinerM30SPlusVG60, "M30S+VH10": BTMinerM30SPlusVH10, "M30S+VH20": BTMinerM30SPlusVH20, "M30S+VH30": BTMinerM30SPlusVH30, "M30S+VH40": BTMinerM30SPlusVH40, "M30S+VH50": BTMinerM30SPlusVH50, "M30S+VH60": BTMinerM30SPlusVH60, "M30S+VH70": BTMinerM30SPlusVH70, "M30S+VI30": BTMinerM30SPlusVI30, "M30S+VJ30": BTMinerM30SPlusVJ30, "M30S+VJ40": BTMinerM30SPlusVJ40, "M30SV10": BTMinerM30SV10, "M30SV20": BTMinerM30SV20, "M30SV30": BTMinerM30SV30, "M30SV40": BTMinerM30SV40, "M30SV50": BTMinerM30SV50, "M30SV60": BTMinerM30SV60, "M30SV70": BTMinerM30SV70, "M30SV80": BTMinerM30SV80, "M30SVE10": BTMinerM30SVE10, "M30SVE20": BTMinerM30SVE20, "M30SVE30": BTMinerM30SVE30, "M30SVE40": BTMinerM30SVE40, "M30SVE50": BTMinerM30SVE50, "M30SVE60": BTMinerM30SVE60, "M30SVE70": BTMinerM30SVE70, "M30SVF10": BTMinerM30SVF10, "M30SVF20": BTMinerM30SVF20, "M30SVF30": BTMinerM30SVF30, "M30SVG10": BTMinerM30SVG10, "M30SVG20": BTMinerM30SVG20, "M30SVG30": BTMinerM30SVG30, "M30SVG40": BTMinerM30SVG40, "M30SVH10": BTMinerM30SVH10, "M30SVH20": BTMinerM30SVH20, "M30SVH30": BTMinerM30SVH30, "M30SVH40": BTMinerM30SVH40, "M30SVH50": BTMinerM30SVH50, "M30SVH60": BTMinerM30SVH60, "M30SVI20": BTMinerM30SVI20, "M30SVJ30": BTMinerM30SVJ30, "M30V10": BTMinerM30V10, "M30V20": BTMinerM30V20, "M31HV10": BTMinerM31HV10, "M31HV40": BTMinerM31HV40, "M31LV10": BTMinerM31LV10, "M31S+V10": BTMinerM31SPlusV10, "M31S+V100": BTMinerM31SPlusV100, "M31S+V20": BTMinerM31SPlusV20, "M31S+V30": BTMinerM31SPlusV30, "M31S+V40": BTMinerM31SPlusV40, "M31S+V50": BTMinerM31SPlusV50, "M31S+V60": BTMinerM31SPlusV60, "M31S+V80": BTMinerM31SPlusV80, "M31S+V90": BTMinerM31SPlusV90, "M31S+VE10": BTMinerM31SPlusVE10, "M31S+VE20": BTMinerM31SPlusVE20, "M31S+VE30": BTMinerM31SPlusVE30, "M31S+VE40": BTMinerM31SPlusVE40, "M31S+VE50": BTMinerM31SPlusVE50, "M31S+VE60": BTMinerM31SPlusVE60, "M31S+VE80": BTMinerM31SPlusVE80, "M31S+VF20": BTMinerM31SPlusVF20, "M31S+VF30": BTMinerM31SPlusVF30, "M31S+VG20": BTMinerM31SPlusVG20, "M31S+VG30": BTMinerM31SPlusVG30, "M31SEV10": BTMinerM31SEV10, "M31SEV20": BTMinerM31SEV20, "M31SEV30": BTMinerM31SEV30, "M31SV10": BTMinerM31SV10, "M31SV20": BTMinerM31SV20, "M31SV30": BTMinerM31SV30, "M31SV40": BTMinerM31SV40, "M31SV50": BTMinerM31SV50, "M31SV60": BTMinerM31SV60, "M31SV70": BTMinerM31SV70, "M31SV80": BTMinerM31SV80, "M31SV90": BTMinerM31SV90, "M31SVE10": BTMinerM31SVE10, "M31SVE20": BTMinerM31SVE20, "M31SVE30": BTMinerM31SVE30, "M31V10": BTMinerM31V10, "M31V20": BTMinerM31V20, "M32V10": BTMinerM32V10, "M32V20": BTMinerM32V20, "M33S++VG40": BTMinerM33SPlusPlusVG40, "M33S++VH20": BTMinerM33SPlusPlusVH20, "M33S++VH30": BTMinerM33SPlusPlusVH30, "M33S+VG20": BTMinerM33SPlusVG20, "M33S+VG30": BTMinerM33SPlusVG30, "M33S+VH20": BTMinerM33SPlusVH20, "M33S+VH30": BTMinerM33SPlusVH30, "M33SVG30": BTMinerM33SVG30, "M33V10": BTMinerM33V10, "M33V20": BTMinerM33V20, "M33V30": BTMinerM33V30, "M34S+VE10": BTMinerM34SPlusVE10, "M36S++VH30": BTMinerM36SPlusPlusVH30, "M36S+VG30": BTMinerM36SPlusVG30, "M36SVE10": BTMinerM36SVE10, "M39V10": BTMinerM39V10, "M39V20": BTMinerM39V20, "M39V30": BTMinerM39V30, "M50S++VK10": BTMinerM50SPlusPlusVK10, "M50S++VK20": BTMinerM50SPlusPlusVK20, "M50S++VK30": BTMinerM50SPlusPlusVK30, "M50S++VK40": BTMinerM50SPlusPlusVK40, "M50S++VK50": BTMinerM50SPlusPlusVK50, "M50S++VK60": BTMinerM50SPlusPlusVK60, "M50S++VL20": BTMinerM50SPlusPlusVL20, "M50S++VL30": BTMinerM50SPlusPlusVL30, "M50S++VL40": BTMinerM50SPlusPlusVL40, "M50S++VL50": BTMinerM50SPlusPlusVL50, "M50S++VL60": BTMinerM50SPlusPlusVL60, "M50S+VH30": BTMinerM50SPlusVH30, "M50S+VH40": BTMinerM50SPlusVH40, "M50S+VJ30": BTMinerM50SPlusVJ30, "M50S+VJ40": BTMinerM50SPlusVJ40, "M50S+VJ60": BTMinerM50SPlusVJ60, "M50S+VK10": BTMinerM50SPlusVK10, "M50S+VK20": BTMinerM50SPlusVK20, "M50S+VK30": BTMinerM50SPlusVK30, "M50S+VL10": BTMinerM50SPlusVL10, "M50S+VL20": BTMinerM50SPlusVL20, "M50S+VL30": BTMinerM50SPlusVL30, "M50SVH10": BTMinerM50SVH10, "M50SVH20": BTMinerM50SVH20, "M50SVH30": BTMinerM50SVH30, "M50SVH40": BTMinerM50SVH40, "M50SVH50": BTMinerM50SVH50, "M50SVJ10": BTMinerM50SVJ10, "M50SVJ20": BTMinerM50SVJ20, "M50SVJ30": BTMinerM50SVJ30, "M50SVJ40": BTMinerM50SVJ40, "M50SVJ50": BTMinerM50SVJ50, "M50SVK10": BTMinerM50SVK10, "M50SVK20": BTMinerM50SVK20, "M50SVK30": BTMinerM50SVK30, "M50SVK50": BTMinerM50SVK50, "M50SVK60": BTMinerM50SVK60, "M50SVK70": BTMinerM50SVK70, "M50SVK80": BTMinerM50SVK80, "M50SVL20": BTMinerM50SVL20, "M50SVL30": BTMinerM50SVL30, "M50VE30": BTMinerM50VE30, "M50VG30": BTMinerM50VG30, "M50VH10": BTMinerM50VH10, "M50VH20": BTMinerM50VH20, "M50VH30": BTMinerM50VH30, "M50VH40": BTMinerM50VH40, "M50VH50": BTMinerM50VH50, "M50VH60": BTMinerM50VH60, "M50VH70": BTMinerM50VH70, "M50VH80": BTMinerM50VH80, "M50VH90": BTMinerM50VH90, "M50VJ10": BTMinerM50VJ10, "M50VJ20": BTMinerM50VJ20, "M50VJ30": BTMinerM50VJ30, "M50VJ40": BTMinerM50VJ40, "M50VJ60": BTMinerM50VJ60, "M50VK40": BTMinerM50VK40, "M50VK50": BTMinerM50VK50, "M52S++VL10": BTMinerM52SPlusPlusVL10, "M52SVK30": BTMinerM52SVK30, "M53HVH10": BTMinerM53HVH10, "M53S++VK10": BTMinerM53SPlusPlusVK10, "M53S++VK20": BTMinerM53SPlusPlusVK20, "M53S++VK30": BTMinerM53SPlusPlusVK30, "M53S++VK50": BTMinerM53SPlusPlusVK50, "M53S++VL10": BTMinerM53SPlusPlusVL10, "M53S++VL30": BTMinerM53SPlusPlusVL30, "M53S+VJ30": BTMinerM53SPlusVJ30, "M53S+VJ40": BTMinerM53SPlusVJ40, "M53S+VJ50": BTMinerM53SPlusVJ50, "M53S+VK30": BTMinerM53SPlusVK30, "M53SVH20": BTMinerM53SVH20, "M53SVH30": BTMinerM53SVH30, "M53SVJ30": BTMinerM53SVJ30, "M53SVJ40": BTMinerM53SVJ40, "M53SVK30": BTMinerM53SVK30, "M53VH30": BTMinerM53VH30, "M53VH40": BTMinerM53VH40, "M53VH50": BTMinerM53VH50, "M53VK30": BTMinerM53VK30, "M53VK60": BTMinerM53VK60, "M54S++VK30": BTMinerM54SPlusPlusVK30, "M54S++VL30": BTMinerM54SPlusPlusVL30, "M54S++VL40": BTMinerM54SPlusPlusVL40, "M56S++VK10": BTMinerM56SPlusPlusVK10, "M56S++VK30": BTMinerM56SPlusPlusVK30, "M56S++VK40": BTMinerM56SPlusPlusVK40, "M56S++VK50": BTMinerM56SPlusPlusVK50, "M56S+VJ30": BTMinerM56SPlusVJ30, "M56S+VK30": BTMinerM56SPlusVK30, "M56S+VK40": BTMinerM56SPlusVK40, "M56S+VK50": BTMinerM56SPlusVK50, "M56SVH30": BTMinerM56SVH30, "M56SVJ30": BTMinerM56SVJ30, "M56SVJ40": BTMinerM56SVJ40, "M56VH30": BTMinerM56VH30, "M59VH30": BTMinerM59VH30, "M60S++VL30": BTMinerM60SPlusPlusVL30, "M60S++VL40": BTMinerM60SPlusPlusVL40, "M60S+VK30": BTMinerM60SPlusVK30, "M60S+VK40": BTMinerM60SPlusVK40, "M60S+VK50": BTMinerM60SPlusVK50, "M60S+VK60": BTMinerM60SPlusVK60, "M60S+VK70": BTMinerM60SPlusVK70, "M60S+VL10": BTMinerM60SPlusVL10, "M60S+VL30": BTMinerM60SPlusVL30, "M60S+VL40": BTMinerM60SPlusVL40, "M60S+VL50": BTMinerM60SPlusVL50, "M60S+VL60": BTMinerM60SPlusVL60, "M60SVK10": BTMinerM60SVK10, "M60SVK20": BTMinerM60SVK20, "M60SVK30": BTMinerM60SVK30, "M60SVK40": BTMinerM60SVK40, "M60SVL10": BTMinerM60SVL10, "M60SVL20": BTMinerM60SVL20, "M60SVL30": BTMinerM60SVL30, "M60SVL40": BTMinerM60SVL40, "M60SVL50": BTMinerM60SVL50, "M60SVL60": BTMinerM60SVL60, "M60SVL70": BTMinerM60SVL70, "M60VK10": BTMinerM60VK10, "M60VK20": BTMinerM60VK20, "M60VK30": BTMinerM60VK30, "M60VK40": BTMinerM60VK40, "M60VK6A": BTMinerM60VK6A, "M60VL10": BTMinerM60VL10, "M60VL20": BTMinerM60VL20, "M60VL30": BTMinerM60VL30, "M60VL40": BTMinerM60VL40, "M60VL50": BTMinerM60VL50, "M61S+VL30": BTMinerM61SPlusVL30, "M61SVL10": BTMinerM61SVL10, "M61SVL20": BTMinerM61SVL20, "M61SVL30": BTMinerM61SVL30, "M61VK10": BTMinerM61VK10, "M61VK20": BTMinerM61VK20, "M61VK30": BTMinerM61VK30, "M61VK40": BTMinerM61VK40, "M61VL10": BTMinerM61VL10, "M61VL30": BTMinerM61VL30, "M61VL40": BTMinerM61VL40, "M61VL50": BTMinerM61VL50, "M61VL60": BTMinerM61VL60, "M62S+VK30": BTMinerM62SPlusVK30, "M63S++VL20": BTMinerM63SPlusPlusVL20, "M63S+VK30": BTMinerM63SPlusVK30, "M63S+VL10": BTMinerM63SPlusVL10, "M63S+VL20": BTMinerM63SPlusVL20, "M63S+VL30": BTMinerM63SPlusVL30, "M63S+VL50": BTMinerM63SPlusVL50, "M63SVK10": BTMinerM63SVK10, "M63SVK20": BTMinerM63SVK20, "M63SVK30": BTMinerM63SVK30, "M63SVK60": BTMinerM63SVK60, "M63SVL10": BTMinerM63SVL10, "M63SVL50": BTMinerM63SVL50, "M63SVL60": BTMinerM63SVL60, "M63VK10": BTMinerM63VK10, "M63VK20": BTMinerM63VK20, "M63VK30": BTMinerM63VK30, "M63VL10": BTMinerM63VL10, "M63VL30": BTMinerM63VL30, "M64SVL30": BTMinerM64SVL30, "M64VL30": BTMinerM64VL30, "M64VL40": BTMinerM64VL40, "M65S+VK30": BTMinerM65SPlusVK30, "M65SVK20": BTMinerM65SVK20, "M65SVL60": BTMinerM65SVL60, "M66S++VL20": BTMinerM66SPlusPlusVL20, "M66S+VK30": BTMinerM66SPlusVK30, "M66S+VL10": BTMinerM66SPlusVL10, "M66S+VL20": BTMinerM66SPlusVL20, "M66S+VL30": BTMinerM66SPlusVL30, "M66S+VL40": BTMinerM66SPlusVL40, "M66S+VL60": BTMinerM66SPlusVL60, "M66SVK20": BTMinerM66SVK20, "M66SVK30": BTMinerM66SVK30, "M66SVK40": BTMinerM66SVK40, "M66SVK50": BTMinerM66SVK50, "M66SVK60": BTMinerM66SVK60, "M66SVL10": BTMinerM66SVL10, "M66SVL20": BTMinerM66SVL20, "M66SVL30": BTMinerM66SVL30, "M66SVL40": BTMinerM66SVL40, "M66SVL50": BTMinerM66SVL50, "M66VK20": BTMinerM66VK20, "M66VK30": BTMinerM66VK30, "M66VL20": BTMinerM66VL20, "M66VL30": BTMinerM66VL30, "M67SVK30": BTMinerM67SVK30, "M70VM30": BTMinerM70VM30, }, MinerTypes.AVALONMINER: { None: type("AvalonUnknown", (AvalonMiner, AvalonMinerMake), {}), "AVALONMINER 721": CGMinerAvalon721, "AVALONMINER 741": CGMinerAvalon741, "AVALONMINER 761": CGMinerAvalon761, "AVALONMINER 821": CGMinerAvalon821, "AVALONMINER 841": CGMinerAvalon841, "AVALONMINER 851": CGMinerAvalon851, "AVALONMINER 921": CGMinerAvalon921, "AVALONMINER 1026": CGMinerAvalon1026, "AVALONMINER 1047": CGMinerAvalon1047, "AVALONMINER 1066": CGMinerAvalon1066, "AVALONMINER 1126PRO": CGMinerAvalon1126Pro, "AVALONMINER 1166PRO": CGMinerAvalon1166Pro, "AVALONMINER 1246": CGMinerAvalon1246, "AVALONMINER NANO3": CGMinerAvalonNano3, "AVALON NANO3S": CGMinerAvalonNano3s, "AVALONMINER 15-194": CGMinerAvalon1566, "AVALON Q": CGMinerAvalonQHome, "AVALON MINI3": CGMinerAvalonMini3, }, MinerTypes.INNOSILICON: { None: type("InnosiliconUnknown", (Innosilicon, InnosiliconMake), {}), "T3H+": InnosiliconT3HPlus, "A10X": InnosiliconA10X, "A11": InnosiliconA11, "A11MX": InnosiliconA11MX, }, MinerTypes.GOLDSHELL: { None: type("GoldshellUnknown", (GoldshellMiner, GoldshellMake), {}), "GOLDSHELL CK5": GoldshellCK5, "GOLDSHELL HS5": GoldshellHS5, "GOLDSHELL KD5": GoldshellKD5, "GOLDSHELL KDMAX": GoldshellKDMax, "GOLDSHELL KDBOXII": GoldshellKDBoxII, "GOLDSHELL KDBOXPRO": GoldshellKDBoxPro, "GOLDSHELL BYTE": GoldshellByte, "GOLDSHELL MINIDOGE": GoldshellMiniDoge, }, MinerTypes.BRAIINS_OS: { None: BOSMiner, "ANTMINER S9": BOSMinerS9, "ANTMINER S17": BOSMinerS17, "ANTMINER S17+": BOSMinerS17Plus, "ANTMINER S17 PRO": BOSMinerS17Pro, "ANTMINER S17E": BOSMinerS17e, "ANTMINER T17": BOSMinerT17, "ANTMINER T17+": BOSMinerT17Plus, "ANTMINER T17E": BOSMinerT17e, "ANTMINER S19": BOSMinerS19, "ANTMINER S19+": BOSMinerS19Plus, "ANTMINER S19 PRO": BOSMinerS19Pro, "ANTMINER S19A": BOSMinerS19a, "ANTMINER S19A Pro": BOSMinerS19aPro, "ANTMINER S19J": BOSMinerS19j, "ANTMINER S19J88NOPIC": BOSMinerS19jNoPIC, "ANTMINER S19J PRO": BOSMinerS19jPro, "ANTMINER S19J PRO NOPIC": BOSMinerS19jProNoPIC, "ANTMINER S19J PRO+": BOSMinerS19jProPlus, "ANTMINER S19J PRO PLUS": BOSMinerS19jProPlus, "ANTMINER S19J PRO PLUS NOPIC": BOSMinerS19jProPlusNoPIC, "ANTMINER S19K PRO NOPIC": BOSMinerS19kProNoPIC, "ANTMINER S19K PRO": BOSMinerS19kProNoPIC, "ANTMINER S19 XP": BOSMinerS19XP, "ANTMINER S19 PRO+ HYD.": BOSMinerS19ProPlusHydro, "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, "ANTMINER S17+": VNishS17Plus, "ANTMINER S17 PRO": VNishS17Pro, "ANTMINER S19": VNishS19, "ANTMINER S19NOPIC": VNishS19NoPIC, "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 S19 PRO HYDRO": 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, "ANTMINER S19 XP+": VNishS19XPPlus, "ANTMINER S19J PRO+": VNishS19jProPlus, "ANTMINER S19J XP": VNishS19jXP, "ANTMINER S21 HYDRO": VNishS21Hydro, }, MinerTypes.EPIC: { None: ePIC, "ANTMINER S19": ePICS19, "ANTMINER S19 PRO": ePICS19Pro, "ANTMINER S19J": ePICS19j, "ANTMINER S19J PRO": ePICS19jPro, "ANTMINER S19J PRO+": ePICS19jProPlus, "ANTMINER S19K PRO": ePICS19kPro, "ANTMINER S19 XP": ePICS19XP, "ANTMINER S21": ePICS21, "ANTMINER S21 PRO": ePICS21Pro, "ANTMINER T21": ePICT21, "ANTMINER S19J PRO DUAL": ePICS19jProDual, "ANTMINER S19K PRO DUAL": ePICS19kProDual, "BLOCKMINER 520I": ePICBlockMiner520i, "BLOCKMINER 720I": ePICBlockMiner720i, "BLOCKMINER ELITE 1.0": ePICBlockMinerELITE1, }, MinerTypes.HIVEON: { None: HiveonModern, "ANTMINER T9": HiveonT9, "ANTMINER S19JPRO": HiveonS19jPro, "ANTMINER S19": HiveonS19, "ANTMINER S19K PRO": HiveonS19kPro, "ANTMINER S19X88": HiveonS19NoPIC, }, MinerTypes.MSKMINER: { None: MSKMiner, "S19-88": MSKMinerS19NoPIC, }, MinerTypes.LUX_OS: { None: LUXMiner, "ANTMINER S9": LUXMinerS9, "ANTMINER S19": LUXMinerS19, "ANTMINER S19 PRO": LUXMinerS19Pro, "ANTMINER S19J PRO": LUXMinerS19jPro, "ANTMINER S19J PRO+": LUXMinerS19jProPlus, "ANTMINER S19K PRO": LUXMinerS19kPro, "ANTMINER S19 XP": LUXMinerS19XP, "ANTMINER T19": LUXMinerT19, "ANTMINER S21": LUXMinerS21, "ANTMINER T21": LUXMinerT21, }, MinerTypes.AURADINE: { None: type("AuradineUnknown", (Auradine, AuradineMake), {}), "AT1500": AuradineFluxAT1500, "AT2860": AuradineFluxAT2860, "AT2880": AuradineFluxAT2880, "AI2500": AuradineFluxAI2500, "AI3680": AuradineFluxAI3680, "AD2500": AuradineFluxAD2500, "AD3500": AuradineFluxAD3500, }, MinerTypes.MARATHON: { None: MaraMiner, "ANTMINER S19": MaraS19, "ANTMINER S19 PRO": MaraS19Pro, "ANTMINER S19J": MaraS19j, "ANTMINER S19J88NOPIC": MaraS19jNoPIC, "ANTMINER S19J PRO": MaraS19jPro, "ANTMINER S19 XP": MaraS19XP, "ANTMINER S19K PRO": MaraS19KPro, "ANTMINER S21": MaraS21, "ANTMINER T21": MaraT21, }, MinerTypes.BITAXE: { None: BitAxe, "BM1368": BitAxeSupra, "BM1366": BitAxeUltra, "BM1397": BitAxeMax, "BM1370": BitAxeGamma, }, MinerTypes.LUCKYMINER: { None: LuckyMiner, "LV08": LuckyMinerLV08, "LV07": LuckyMinerLV07, }, MinerTypes.ICERIVER: { None: type("IceRiverUnknown", (IceRiver, IceRiverMake), {}), "KS0": IceRiverKS0, "KS1": IceRiverKS1, "KS2": IceRiverKS2, "KS3": IceRiverKS3, "KS3L": IceRiverKS3L, "KS3M": IceRiverKS3M, "KS5": IceRiverKS5, "KS5L": IceRiverKS5L, "KS5M": IceRiverKS5M, "10306": IceRiverAL3, }, MinerTypes.HAMMER: { None: type("HammerUnknown", (BlackMiner, HammerMake), {}), "HAMMER D10": HammerD10, }, MinerTypes.VOLCMINER: { None: type("VolcMinerUnknown", (BlackMiner, VolcMinerMake), {}), "VOLCMINER D1": VolcMinerD1, }, MinerTypes.ELPHAPEX: { None: type("ElphapexUnknown", (ElphapexMiner, ElphapexMake), {}), "DG1+": ElphapexDG1Plus, "DG1": ElphapexDG1, "DG1-Home": ElphapexDG1Home, }, } async def concurrent_get_first_result(tasks: list, verification_func: Callable) -> Any: res = None for fut in asyncio.as_completed(tasks): res = await fut if verification_func(res): break for t in tasks: t.cancel() try: await t except asyncio.CancelledError: pass return res class MinerFactory: async def get_multiple_miners( self, ips: list[str], limit: int = 200 ) -> list[AnyMiner]: results: list[AnyMiner] = [] miner: AnyMiner async for miner in self.get_miner_generator(ips, limit): results.append(miner) return results async def get_miner_generator( self, ips: list, limit: int = 200 ) -> AsyncGenerator[AnyMiner, None]: tasks = [] semaphore = asyncio.Semaphore(limit) for ip in ips: tasks.append(asyncio.create_task(self.get_miner(ip))) for task in tasks: async with semaphore: result = await task # type: ignore[func-returns-value] if result is not None: yield result async def get_miner( self, ip: str | ipaddress.IPv4Address | ipaddress.IPv6Address ) -> AnyMiner | None: ip = str(ip) miner_type = None for _ in range(settings.get("factory_get_retries", 1)): task = asyncio.create_task(self._get_miner_type(ip)) try: miner_type = await asyncio.wait_for( task, timeout=settings.get("factory_get_timeout", 3) ) except asyncio.TimeoutError: continue else: if miner_type is not None: break if miner_type is not None: miner_model: str | None = None miner_model_fns = { MinerTypes.ANTMINER: self.get_miner_model_antminer, MinerTypes.WHATSMINER: self.get_miner_model_whatsminer, MinerTypes.AVALONMINER: self.get_miner_model_avalonminer, MinerTypes.INNOSILICON: self.get_miner_model_innosilicon, MinerTypes.GOLDSHELL: self.get_miner_model_goldshell, MinerTypes.BRAIINS_OS: self.get_miner_model_braiins_os, MinerTypes.VNISH: self.get_miner_model_vnish, MinerTypes.EPIC: self.get_miner_model_epic, MinerTypes.HIVEON: self.get_miner_model_hiveon, MinerTypes.LUX_OS: self.get_miner_model_luxos, MinerTypes.AURADINE: self.get_miner_model_auradine, MinerTypes.MARATHON: self.get_miner_model_marathon, MinerTypes.BITAXE: self.get_miner_model_bitaxe, MinerTypes.LUCKYMINER: self.get_miner_model_luckyminer, MinerTypes.ICERIVER: self.get_miner_model_iceriver, MinerTypes.HAMMER: self.get_miner_model_hammer, MinerTypes.VOLCMINER: self.get_miner_model_volcminer, MinerTypes.ELPHAPEX: self.get_miner_model_elphapex, } version: str | None = None miner_version_fns = { MinerTypes.WHATSMINER: self.get_miner_version_whatsminer, } model_fn = miner_model_fns.get(miner_type) version_fn = miner_version_fns.get(miner_type) if model_fn is not None: # noinspection PyArgumentList model_task = asyncio.create_task(model_fn(ip)) try: miner_model = await asyncio.wait_for( model_task, timeout=settings.get("factory_get_timeout", 3) ) except asyncio.TimeoutError: pass if version_fn is not None: version_task = asyncio.create_task(version_fn(ip)) try: version = await asyncio.wait_for( version_task, timeout=settings.get("factory_get_timeout", 3) ) except asyncio.TimeoutError: pass miner = self._select_miner_from_classes( ip, miner_type=miner_type, miner_model=miner_model, version=version ) return miner return None async def _get_miner_type(self, ip: str) -> MinerTypes | None: tasks = [ asyncio.create_task(self._get_miner_web(ip)), asyncio.create_task(self._get_miner_socket(ip)), ] return await concurrent_get_first_result(tasks, lambda x: x is not None) async def _get_miner_web(self, ip: str) -> MinerTypes | None: urls = [f"http://{ip}/", f"https://{ip}/"] async with httpx.AsyncClient( transport=settings.transport(verify=False) ) as session: tasks = [asyncio.create_task(self._web_ping(session, url)) for url in urls] text, resp = await concurrent_get_first_result( tasks,
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
true
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/pyasic/miners/__init__.py
pyasic/miners/__init__.py
# ------------------------------------------------------------------------------ # 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 .base import AnyMiner from .data import DataOptions from .factory import get_miner, miner_factory from .listener import MinerListener
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/pyasic/miners/base.py
pyasic/miners/base.py
# ------------------------------------------------------------------------------ # 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. - # ------------------------------------------------------------------------------ import asyncio import ipaddress import warnings from typing import Any, Protocol, TypeVar from pyasic.config import MinerConfig from pyasic.data import Fan, HashBoard, MinerData from pyasic.data.device import DeviceInfo from pyasic.data.error_codes import MinerErrorData from pyasic.data.pools import PoolMetrics from pyasic.device.algorithm import AlgoHashRateType, MinerAlgoType from pyasic.device.algorithm.base import GenericAlgo from pyasic.device.firmware import MinerFirmware from pyasic.device.makes import MinerMake from pyasic.device.models import MinerModelType from pyasic.errors import APIError from pyasic.logger import logger from pyasic.miners.data import DataOptions, RPCAPICommand, WebAPICommand class MinerProtocol(Protocol): _rpc_cls: type[Any] | None = None _web_cls: type[Any] | None = None _ssh_cls: type[Any] | None = None ip: str | None = None rpc: Any | None = None web: Any | None = None ssh: Any | None = None make: MinerMake | None = None raw_model: MinerModelType | None = None firmware: MinerFirmware | None = None algo: type[MinerAlgoType] = GenericAlgo expected_hashboards: int | None = None expected_chips: int | None = None expected_fans: int | None = None data_locations: Any | None = None supports_shutdown: bool = False supports_power_modes: bool = False supports_presets: bool = False supports_autotuning: bool = False api_ver: str | None = None fw_ver: str | None = None light: bool | None = None config: MinerConfig | None = None def __repr__(self): return f"{self.model}: {str(self.ip)}" def __lt__(self, other): return ipaddress.ip_address(self.ip) < ipaddress.ip_address(other.ip) def __gt__(self, other): return ipaddress.ip_address(self.ip) > ipaddress.ip_address(other.ip) def __eq__(self, other): return ipaddress.ip_address(self.ip) == ipaddress.ip_address(other.ip) @property def model(self) -> str: if self.raw_model is not None: model_data = [str(self.raw_model)] elif self.make is not None: model_data = [str(self.make)] else: model_data = ["Unknown"] if self.firmware is not None: model_data.append(f"({self.firmware})") return " ".join(model_data) @property def device_info(self) -> DeviceInfo: return DeviceInfo( make=self.make, model=self.raw_model, firmware=self.firmware, algo=self.algo ) @property def api(self): return self.rpc async def check_light(self) -> bool: """Get the status of the fault light as a boolean. Returns: A boolean value representing the fault light status. """ return await self.get_fault_light() async def fault_light_on(self) -> bool: """Turn the fault light of the miner on and return success as a boolean. Returns: A boolean value of the success of turning the light on. """ return False async def fault_light_off(self) -> bool: """Turn the fault light of the miner off and return success as a boolean. Returns: A boolean value of the success of turning the light off. """ return False async def get_config(self) -> MinerConfig: # Not a data gathering function, since this is used for configuration """Get the mining configuration of the miner and return it as a [`MinerConfig`][pyasic.config.MinerConfig]. Returns: A [`MinerConfig`][pyasic.config.MinerConfig] containing the pool information and mining configuration. """ return MinerConfig() async def reboot(self) -> bool: """Reboot the miner and return success as a boolean. Returns: A boolean value of the success of rebooting the miner. """ return False async def restart_backend(self) -> bool: """Restart the mining process of the miner (bosminer, bmminer, cgminer, etc) and return success as a boolean. Returns: A boolean value of the success of restarting the mining process. """ return False async def send_config( self, config: MinerConfig, user_suffix: str | None = None ) -> None: """Set the mining configuration of the miner. Parameters: config: A [`MinerConfig`][pyasic.config.MinerConfig] containing the mining config you want to switch the miner to. user_suffix: A suffix to append to the username when sending to the miner. """ return None async def stop_mining(self) -> bool: """Stop the mining process of the miner. Returns: A boolean value of the success of stopping the mining process. """ return False async def resume_mining(self) -> bool: """Resume the mining process of the miner. Returns: A boolean value of the success of resuming the mining process. """ return False async def set_power_limit(self, wattage: int) -> bool: """Set the power limit to be used by the miner. Parameters: wattage: The power limit to set on the miner. Returns: A boolean value of the success of setting the power limit. """ return False async def upgrade_firmware( self, *, file: str | None = None, url: str | None = None, version: str | None = None, keep_settings: bool = True, ) -> bool: """Upgrade the firmware of the miner. Parameters: file: The file path to the firmware to upgrade from. Must be a valid file path if provided. url: The URL to download the firmware from. Must be a valid URL if provided. version: The version of the firmware to upgrade to. If None, the version will be inferred from the file or URL. keep_settings: Whether to keep the current settings during the upgrade. Defaults to True. Returns: A boolean value of the success of the firmware upgrade. """ return False ################################################## ### DATA GATHERING FUNCTIONS (get_{some_data}) ### ################################################## async def get_serial_number(self) -> str | None: """Get the serial number of the miner and return it as a string. Returns: A string representing the serial number of the miner. """ return await self._get_serial_number() async def get_mac(self) -> str | None: """Get the MAC address of the miner and return it as a string. Returns: A string representing the MAC address of the miner. """ return await self._get_mac() async def get_model(self) -> str | None: """Get the model of the miner and return it as a string. Returns: A string representing the model of the miner. """ return self.model async def get_device_info(self) -> DeviceInfo | None: """Get device information, including model, make, and firmware. Returns: A dataclass containing device information. """ return self.device_info async def get_api_ver(self) -> str | None: """Get the API version of the miner and is as a string. Returns: API version as a string. """ return await self._get_api_ver() async def get_fw_ver(self) -> str | None: """Get the firmware version of the miner and is as a string. Returns: Firmware version as a string. """ return await self._get_fw_ver() async def get_version(self) -> tuple[str | None, str | None]: """Get the API version and firmware version of the miner and return them as strings. Returns: A tuple of (API version, firmware version) as strings. """ api_ver = await self.get_api_ver() fw_ver = await self.get_fw_ver() return api_ver, fw_ver async def get_hostname(self) -> str | None: """Get the hostname of the miner and return it as a string. Returns: A string representing the hostname of the miner. """ return await self._get_hostname() async def get_hashrate(self) -> AlgoHashRateType | None: """Get the hashrate of the miner and return it as a float in TH/s. Returns: Hashrate of the miner in TH/s as a float. """ return await self._get_hashrate() async def get_hashboards(self) -> list[HashBoard]: """Get hashboard data from the miner in the form of [`HashBoard`][pyasic.data.HashBoard]. Returns: A [`HashBoard`][pyasic.data.HashBoard] instance containing hashboard data from the miner. """ return await self._get_hashboards() async def get_env_temp(self) -> float | None: """Get environment temp from the miner as a float. Returns: Environment temp of the miner as a float. """ return await self._get_env_temp() async def get_wattage(self) -> int | None: """Get wattage from the miner as an int. Returns: Wattage of the miner as an int. """ return await self._get_wattage() async def get_voltage(self) -> float | None: """Get output voltage of the PSU as a float. Returns: Output voltage of the PSU as an float. """ return await self._get_voltage() async def get_wattage_limit(self) -> int | None: """Get wattage limit from the miner as an int. Returns: Wattage limit of the miner as an int. """ return await self._get_wattage_limit() async def get_fans(self) -> list[Fan]: """Get fan data from the miner in the form [fan_1, fan_2, fan_3, fan_4]. Returns: A list of fan data. """ return await self._get_fans() async def get_fan_psu(self) -> int | None: """Get PSU fan speed from the miner. Returns: PSU fan speed. """ return await self._get_fan_psu() async def get_errors(self) -> list[MinerErrorData]: """Get a list of the errors the miner is experiencing. Returns: A list of error classes representing different errors. """ return await self._get_errors() async def get_fault_light(self) -> bool: """Check the status of the fault light and return on or off as a boolean. Returns: A boolean value where `True` represents on and `False` represents off. """ result = await self._get_fault_light() return result if result is not None else False async def get_expected_hashrate(self) -> AlgoHashRateType | None: """Get the nominal hashrate from factory if available. Returns: A float value of nominal hashrate in TH/s. """ return await self._get_expected_hashrate() async def is_mining(self) -> bool | None: """Check whether the miner is mining. Returns: A boolean value representing if the miner is mining. """ return await self._is_mining() async def get_uptime(self) -> int | None: """Get the uptime of the miner in seconds. Returns: The uptime of the miner in seconds. """ return await self._get_uptime() async def get_pools(self) -> list[PoolMetrics]: """Get the pools information from Miner. Returns: The pool information of the miner. """ return await self._get_pools() async def _get_serial_number(self) -> str | None: pass async def _get_mac(self) -> str | None: return None async def _get_api_ver(self) -> str | None: return None async def _get_fw_ver(self) -> str | None: return None async def _get_hostname(self) -> str | None: return None async def _get_hashrate(self) -> AlgoHashRateType | None: return None async def _get_hashboards(self) -> list[HashBoard]: return [] async def _get_env_temp(self) -> float | None: return None async def _get_wattage(self) -> int | None: return None async def _get_voltage(self) -> float | None: return None async def _get_wattage_limit(self) -> int | None: return None async def _get_fans(self) -> list[Fan]: return [] async def _get_fan_psu(self) -> int | None: return None async def _get_errors(self) -> list[MinerErrorData]: return [] async def _get_fault_light(self) -> bool | None: return None async def _get_expected_hashrate(self) -> AlgoHashRateType | None: return None async def _is_mining(self) -> bool | None: return None async def _get_uptime(self) -> int | None: return None async def _get_pools(self) -> list[PoolMetrics]: return [] async def _get_data( self, allow_warning: bool, include: list[str | DataOptions] | None = None, exclude: list[str | DataOptions] | None = None, ) -> dict: # handle include if include is not None: include = [str(i) for i in include] else: # everything include = [str(enum_value.value) for enum_value in DataOptions] # handle exclude # prioritized over include, including x and excluding x will exclude x if exclude is not None: for item in exclude: if str(item) in include: include.remove(str(item)) rpc_multicommand = set() web_multicommand = set() # create multicommand for data_name in include: try: # get kwargs needed for the _get_xyz function fn_args = getattr(self.data_locations, str(data_name)).kwargs # keep track of which RPC/Web commands need to be sent for arg in fn_args: if isinstance(arg, RPCAPICommand): rpc_multicommand.add(arg.cmd) if isinstance(arg, WebAPICommand): web_multicommand.add(arg.cmd) except KeyError as e: logger.error(type(e), e, data_name) continue # create tasks for all commands that need to be sent, or no-op with sleep(0) -> None if ( len(rpc_multicommand) > 0 and self.rpc is not None and hasattr(self.rpc, "multicommand") ): rpc_command_task = asyncio.create_task( self.rpc.multicommand(*rpc_multicommand, allow_warning=allow_warning) ) else: rpc_command_task = asyncio.create_task(asyncio.sleep(0)) if ( len(web_multicommand) > 0 and self.web is not None and hasattr(self.web, "multicommand") ): web_command_task = asyncio.create_task( self.web.multicommand(*web_multicommand, allow_warning=allow_warning) ) else: web_command_task = asyncio.create_task(asyncio.sleep(0)) # make sure the tasks complete await asyncio.gather(rpc_command_task, web_command_task) # grab data out of the tasks web_command_data = web_command_task.result() if web_command_data is None: web_command_data = {} api_command_data = rpc_command_task.result() if api_command_data is None: api_command_data = {} miner_data = {} for data_name in include: try: fn_args = getattr(self.data_locations, str(data_name)).kwargs args_to_send = {k.name: None for k in fn_args} for arg in fn_args: try: if isinstance(arg, RPCAPICommand): if api_command_data.get("multicommand"): args_to_send[arg.name] = api_command_data[arg.cmd][0] else: args_to_send[arg.name] = api_command_data if isinstance(arg, WebAPICommand): if web_command_data is not None: if web_command_data.get("multicommand"): args_to_send[arg.name] = web_command_data[arg.cmd] else: if not web_command_data == {"multicommand": False}: args_to_send[arg.name] = web_command_data except LookupError: args_to_send[arg.name] = None except LookupError: continue try: function = getattr( self, getattr(self.data_locations, str(data_name)).cmd ) miner_data[data_name] = await function(**args_to_send) except Exception as e: raise APIError( f"Failed to call {data_name} on {self} while getting data." ) from e return miner_data async def get_data( self, allow_warning: bool = False, include: list[str | DataOptions] | None = None, exclude: list[str | DataOptions] | None = None, ) -> MinerData: """Get data from the miner in the form of [`MinerData`][pyasic.data.MinerData]. Parameters: allow_warning: Allow warning when an API command fails. include: Names of data items you want to gather. Defaults to all data. exclude: Names of data items to exclude. Exclusion happens after considering included items. Returns: A [`MinerData`][pyasic.data.MinerData] instance containing data from the miner. """ data = MinerData( ip=str(self.ip), device_info=self.device_info, expected_chips=( self.expected_chips * self.expected_hashboards if self.expected_chips is not None and self.expected_hashboards is not None else 0 ), expected_hashboards=self.expected_hashboards, expected_fans=self.expected_fans, hashboards=[ HashBoard(slot=i, expected_chips=self.expected_chips) for i in range( self.expected_hashboards if self.expected_hashboards is not None else 0 ) ], ) gathered_data = await self._get_data( allow_warning=allow_warning, include=include, exclude=exclude ) for item in gathered_data: if gathered_data[item] is not None: setattr(data, item, gathered_data[item]) return data class BaseMiner(MinerProtocol): def __init__(self, ip: str, version: str | None = None) -> None: self.ip = ip if self.expected_chips is None and self.raw_model is not None: warnings.warn( f"Unknown chip count for miner type {self.raw_model}, " f"please open an issue on GitHub (https://github.com/UpstreamData/pyasic)." ) # interfaces if self._rpc_cls is not None: self.rpc = self._rpc_cls(ip) if self._web_cls is not None: self.web = self._web_cls(ip) if self._ssh_cls is not None: self.ssh = self._ssh_cls(ip) AnyMiner = TypeVar("AnyMiner", bound=BaseMiner)
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/pyasic/miners/listener.py
pyasic/miners/listener.py
# ------------------------------------------------------------------------------ # 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. - # ------------------------------------------------------------------------------ import asyncio class MinerListenerProtocol(asyncio.Protocol): def __init__(self): self.responses = {} self.transport = None self.new_miner = None async def get_new_miner(self): try: while self.new_miner is None: await asyncio.sleep(0) return self.new_miner finally: self.new_miner = None def connection_made(self, transport): self.transport = transport def datagram_received(self, data, _addr): if data == b"OK\x00\x00\x00\x00\x00\x00\x00\x00": return m = data.decode() if "," in m: ip, mac = m.split(",") if "/" in ip: ip = ip.replace("[", "").split("/")[0] else: d = m[:-1].split("MAC") ip = d[0][3:] mac = d[1][1:] self.new_miner = {"IP": ip, "MAC": mac.upper()} def connection_lost(self, _): pass class MinerListener: def __init__(self, bind_addr: str = "0.0.0.0"): self.found_miners: list[dict[str, str]] = [] self.stop = asyncio.Event() self.bind_addr = bind_addr async def listen(self): loop = asyncio.get_running_loop() transport_14235, protocol_14235 = await loop.create_datagram_endpoint( MinerListenerProtocol, local_addr=(self.bind_addr, 14235) ) transport_8888, protocol_8888 = await loop.create_datagram_endpoint( MinerListenerProtocol, local_addr=(self.bind_addr, 8888) ) try: while not self.stop.is_set(): tasks = [ asyncio.create_task(protocol_14235.get_new_miner()), asyncio.create_task(protocol_8888.get_new_miner()), ] await asyncio.wait(tasks, return_when=asyncio.FIRST_COMPLETED) for t in tasks: if t.done(): yield t.result() finally: transport_14235.close() transport_8888.close() async def cancel(self): self.stop = True
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/pyasic/miners/data.py
pyasic/miners/data.py
# ------------------------------------------------------------------------------ # 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 dataclasses import dataclass, field, make_dataclass from enum import Enum class DataOptions(Enum): SERIAL_NUMBER = "serial_number" MAC = "mac" API_VERSION = "api_ver" FW_VERSION = "fw_ver" HOSTNAME = "hostname" HASHRATE = "hashrate" EXPECTED_HASHRATE = "expected_hashrate" HASHBOARDS = "hashboards" ENVIRONMENT_TEMP = "env_temp" WATTAGE = "wattage" WATTAGE_LIMIT = "wattage_limit" FANS = "fans" FAN_PSU = "fan_psu" ERRORS = "errors" FAULT_LIGHT = "fault_light" IS_MINING = "is_mining" UPTIME = "uptime" CONFIG = "config" POOLS = "pools" def __str__(self): return self.value def default_command(self): if str(self.value) == "config": return "get_config" elif str(self.value) == "is_mining": return "_is_mining" else: return f"_get_{str(self.value)}" @dataclass class RPCAPICommand: name: str cmd: str @dataclass class WebAPICommand: name: str cmd: str @dataclass class DataFunction: cmd: str kwargs: list[RPCAPICommand | WebAPICommand] = field(default_factory=list) def __call__(self, *args, **kwargs): return self DataLocations = make_dataclass( "DataLocations", [ ( enum_value.value, DataFunction, field(default_factory=DataFunction(enum_value.default_command())), ) for enum_value in DataOptions ], )
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/pyasic/miners/hammer/__init__.py
pyasic/miners/hammer/__init__.py
from .blackminer import *
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/pyasic/miners/hammer/blackminer/__init__.py
pyasic/miners/hammer/blackminer/__init__.py
from .DX import *
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/pyasic/miners/hammer/blackminer/DX/D10.py
pyasic/miners/hammer/blackminer/DX/D10.py
from pyasic.device.algorithm.hashrate.unit.scrypt import ScryptUnit from pyasic.device.algorithm.scrypt import ScryptHashRate from pyasic.miners.backends import BlackMiner from pyasic.miners.device.models import D10 class HammerD10(BlackMiner, D10): sticker_hashrate = ScryptHashRate(rate=5.0, unit=ScryptUnit.GH)
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/pyasic/miners/hammer/blackminer/DX/__init__.py
pyasic/miners/hammer/blackminer/DX/__init__.py
from .D10 import HammerD10
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/pyasic/miners/device/makes.py
pyasic/miners/device/makes.py
# ------------------------------------------------------------------------------ # 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.makes import MinerMake from pyasic.miners.base import BaseMiner class WhatsMinerMake(BaseMiner): make = MinerMake.WHATSMINER class AntMinerMake(BaseMiner): make = MinerMake.ANTMINER class AvalonMinerMake(BaseMiner): make = MinerMake.AVALONMINER class InnosiliconMake(BaseMiner): make = MinerMake.INNOSILICON class GoldshellMake(BaseMiner): make = MinerMake.GOLDSHELL class AuradineMake(BaseMiner): make = MinerMake.AURADINE class ePICMake(BaseMiner): make = MinerMake.EPIC class BitAxeMake(BaseMiner): make = MinerMake.BITAXE class LuckyMinerMake(BaseMiner): make = MinerMake.LUCKYMINER class IceRiverMake(BaseMiner): make = MinerMake.ICERIVER class HammerMake(BaseMiner): make = MinerMake.HAMMER class VolcMinerMake(BaseMiner): make = MinerMake.VOLCMINER class BraiinsMake(BaseMiner): make = MinerMake.BRAIINS class ElphapexMake(BaseMiner): make = MinerMake.ELPHAPEX
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/pyasic/miners/device/firmware.py
pyasic/miners/device/firmware.py
# ------------------------------------------------------------------------------ # 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.firmware import MinerFirmware from pyasic.miners.base import BaseMiner class StockFirmware(BaseMiner): firmware = MinerFirmware.STOCK class BraiinsOSFirmware(BaseMiner): firmware = MinerFirmware.BRAIINS_OS class VNishFirmware(BaseMiner): firmware = MinerFirmware.VNISH class ePICFirmware(BaseMiner): firmware = MinerFirmware.EPIC class HiveonFirmware(BaseMiner): firmware = MinerFirmware.HIVEON class LuxOSFirmware(BaseMiner): firmware = MinerFirmware.LUXOS class MaraFirmware(BaseMiner): firmware = MinerFirmware.MARATHON
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/pyasic/miners/device/__init__.py
pyasic/miners/device/__init__.py
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/pyasic/miners/device/models/__init__.py
pyasic/miners/device/models/__init__.py
# ------------------------------------------------------------------------------ # 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 .antminer import * from .auradine import * from .avalonminer import * from .braiins import * from .elphapex import * from .epic import * from .goldshell import * from .hammer import * from .iceriver import * from .innosilicon import * from .volcminer import * from .whatsminer import *
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/pyasic/miners/device/models/hammer/__init__.py
pyasic/miners/device/models/hammer/__init__.py
from .DX import *
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/pyasic/miners/device/models/hammer/DX/D10.py
pyasic/miners/device/models/hammer/DX/D10.py
# ------------------------------------------------------------------------------ # 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 HammerMake class D10(HammerMake): raw_model = MinerModel.HAMMER.D10 expected_chips = 108 expected_hashboards = 3 expected_fans = 2 algo = MinerAlgo.SCRYPT
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false
UpstreamData/pyasic
https://github.com/UpstreamData/pyasic/blob/820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3/pyasic/miners/device/models/hammer/DX/__init__.py
pyasic/miners/device/models/hammer/DX/__init__.py
from .D10 import D10
python
Apache-2.0
820d2aafdaa6bf2b046f94c017bf7ea58b7c50f3
2026-01-05T07:14:50.237218Z
false