Compare commits
204 Commits
v0.5.0
...
v0.8.4-rc1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5261b00aad | ||
|
|
f18d37a19e | ||
|
|
7c3af3da41 | ||
|
|
8948af55f2 | ||
|
|
dd8fe41ad1 | ||
|
|
198eedcd43 | ||
|
|
f7309decdb | ||
|
|
078579d8e1 | ||
|
|
39eeb13409 | ||
|
|
dfccd67ccb | ||
|
|
10949225c0 | ||
|
|
3a60a3584a | ||
|
|
480aab550c | ||
|
|
fa83e61249 | ||
|
|
2f3411e12d | ||
|
|
3e7311687e | ||
|
|
bc2d549ce5 | ||
|
|
3d31d89c9e | ||
|
|
15fc27e6fa | ||
|
|
943ebc77a1 | ||
|
|
733437ef03 | ||
|
|
b444245e98 | ||
|
|
481d31a0f1 | ||
|
|
264db3bdd6 | ||
|
|
d292b9c195 | ||
|
|
dce25a679f | ||
|
|
c903631742 | ||
|
|
e70bfdc886 | ||
|
|
8e1803add1 | ||
|
|
7d61056ea3 | ||
|
|
0d497baa45 | ||
|
|
d3a71c5a93 | ||
|
|
895a5b7ac8 | ||
|
|
7a5a0b287c | ||
|
|
c7d73276c8 | ||
|
|
4bbb9d0b08 | ||
|
|
3ee49e6fd7 | ||
|
|
dcd3e99d73 | ||
|
|
64018cdad8 | ||
|
|
e7d269008c | ||
|
|
7dfe25e5d2 | ||
|
|
382f9cff76 | ||
|
|
a5195ff1db | ||
|
|
b1ec726d18 | ||
|
|
5ae2cb2b22 | ||
|
|
472a15f4ca | ||
|
|
7cc7973587 | ||
|
|
ab964e4c88 | ||
|
|
4087874b4a | ||
|
|
844deec0d3 | ||
|
|
d36eef4c33 | ||
|
|
69d4ee5570 | ||
|
|
e6d3ec01fe | ||
|
|
e7b01ccdab | ||
|
|
38506903ea | ||
|
|
c9a1560052 | ||
|
|
88f8ff10b7 | ||
|
|
11d38c9c3b | ||
|
|
0082037f45 | ||
|
|
dd5ccafa1e | ||
|
|
739126935a | ||
|
|
5c850a43a9 | ||
|
|
24b037f273 | ||
|
|
f847700c05 | ||
|
|
69820dd9d2 | ||
|
|
ad4b710cb7 | ||
|
|
c53c18654b | ||
|
|
18797f4b56 | ||
|
|
e86c93e287 | ||
|
|
89cfde28f5 | ||
|
|
0f2a867828 | ||
|
|
4f5aef2d45 | ||
|
|
96801f93d1 | ||
|
|
a8ce73c3d6 | ||
|
|
513dd2b981 | ||
|
|
c35b30e949 | ||
|
|
942f2a1c8d | ||
|
|
9078df680e | ||
|
|
527997cc58 | ||
|
|
41433bcaf5 | ||
|
|
3451b88669 | ||
|
|
a42af2764e | ||
|
|
baaad73eb8 | ||
|
|
34c9f85098 | ||
|
|
d6638fa4d2 | ||
|
|
0f51487d3f | ||
|
|
3a11b173c3 | ||
|
|
568f86700b | ||
|
|
3b702aac2c | ||
|
|
6fbd9faffd | ||
|
|
9eb2259aae | ||
|
|
149c386a4c | ||
|
|
726e7ff0f0 | ||
|
|
87a690eb00 | ||
|
|
fd5dba4036 | ||
|
|
e54847337a | ||
|
|
3ff43c3ccd | ||
|
|
ec5563f2f0 | ||
|
|
40f14876cc | ||
|
|
6abfe8a503 | ||
|
|
0a4d52ef03 | ||
|
|
e4207e0120 | ||
|
|
ed89476866 | ||
|
|
7f7964526c | ||
|
|
85b282740a | ||
|
|
8cbf3a20a3 | ||
|
|
8ebcbd3c33 | ||
|
|
c3e285a9ee | ||
|
|
9f19b42de5 | ||
|
|
3d265e823b | ||
|
|
5e6bc8c8ef | ||
|
|
871499b77f | ||
|
|
117a161fd5 | ||
|
|
40bacbf41c | ||
|
|
e091863aa7 | ||
|
|
85e8ac63f1 | ||
|
|
a5252e3a84 | ||
|
|
404d6590db | ||
|
|
1d04399daf | ||
|
|
03ebcacca5 | ||
|
|
75934fd7fe | ||
|
|
bbeca15799 | ||
|
|
45befb569b | ||
|
|
61334ed99e | ||
|
|
2bf059df01 | ||
|
|
9c2de26182 | ||
|
|
714983cddc | ||
|
|
191f1d24b9 | ||
|
|
5a0bafb964 | ||
|
|
67aedd319d | ||
|
|
44012c50d6 | ||
|
|
06540efc98 | ||
|
|
9d0d1a24d9 | ||
|
|
8568f91482 | ||
|
|
64918e5552 | ||
|
|
53d5ecd04a | ||
|
|
1b0e80a418 | ||
|
|
9ad506a313 | ||
|
|
18c4bbd09c | ||
|
|
0d123d5dd8 | ||
|
|
b9b91293fe | ||
|
|
47a702c94c | ||
|
|
6d5a288120 | ||
|
|
038aae95ac | ||
|
|
dd84aede25 | ||
|
|
dc8ad271de | ||
|
|
b78c1cdca5 | ||
|
|
0eb7ced932 | ||
|
|
8e58f4492f | ||
|
|
95fb32de19 | ||
|
|
5145dc19f8 | ||
|
|
1808d62bba | ||
|
|
97ef4dfe37 | ||
|
|
174a132e75 | ||
|
|
84d6e58ebe | ||
|
|
e9a1483e5f | ||
|
|
4eb51eed20 | ||
|
|
066fc1a4b3 | ||
|
|
cc24236c0a | ||
|
|
564cd42eae | ||
|
|
8677eff491 | ||
|
|
63a21ea9aa | ||
|
|
1c9d3dc84d | ||
|
|
0dacd3d294 | ||
|
|
6fa74613b4 | ||
|
|
f7fb7a3acb | ||
|
|
666c5bfc64 | ||
|
|
1f8d92f6bb | ||
|
|
ef336a9e23 | ||
|
|
7fe6fd47fb | ||
|
|
91a0298d96 | ||
|
|
ed3d8fc815 | ||
|
|
4f2d630746 | ||
|
|
a8c685a883 | ||
|
|
09660e1934 | ||
|
|
c01908ff9a | ||
|
|
267c388a95 | ||
|
|
8215d33241 | ||
|
|
f4258a304a | ||
|
|
514fafea58 | ||
|
|
e324369fe0 | ||
|
|
3bc9287668 | ||
|
|
d90bf190c5 | ||
|
|
8cc6f66458 | ||
|
|
a2b071af4f | ||
|
|
b7b589802f | ||
|
|
93912a6df6 | ||
|
|
ffce15f653 | ||
|
|
725b14e583 | ||
|
|
26c6e47f1e | ||
|
|
51dae7375f | ||
|
|
801cfc4ff8 | ||
|
|
ac3ff7a63e | ||
|
|
1b22810f4b | ||
|
|
b756c9e4a1 | ||
|
|
64b5e6c032 | ||
|
|
a13f5dd2d1 | ||
|
|
e6ea8d3e16 | ||
|
|
af37850289 | ||
|
|
6ecdfa1cf8 | ||
|
|
c0b21ebc23 | ||
|
|
184ada417f | ||
|
|
b636860ecb | ||
|
|
0107fdacde |
7
.gitignore
vendored
Normal file
7
.gitignore
vendored
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
venv/
|
||||||
|
build/
|
||||||
|
__pycache__/
|
||||||
|
pyvenv.cfg
|
||||||
|
.env/
|
||||||
|
bin/
|
||||||
|
lib/
|
||||||
@@ -59,7 +59,9 @@ class BaseMinerAPI:
|
|||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
|
||||||
async def multicommand(self, *commands: str) -> dict:
|
async def multicommand(
|
||||||
|
self, *commands: str, ignore_x19_error: bool = False
|
||||||
|
) -> dict:
|
||||||
"""Creates and sends multiple commands as one command to the miner."""
|
"""Creates and sends multiple commands as one command to the miner."""
|
||||||
logging.debug(f"{self.ip}: Sending multicommand: {[*commands]}")
|
logging.debug(f"{self.ip}: Sending multicommand: {[*commands]}")
|
||||||
# split the commands into a proper list
|
# split the commands into a proper list
|
||||||
@@ -78,8 +80,8 @@ If you are sure you want to use this command please use API.send_command("{item}
|
|||||||
command = "+".join(commands)
|
command = "+".join(commands)
|
||||||
data = None
|
data = None
|
||||||
try:
|
try:
|
||||||
data = await self.send_command(command)
|
data = await self.send_command(command, x19_command=ignore_x19_error)
|
||||||
except APIError as e:
|
except APIError:
|
||||||
try:
|
try:
|
||||||
data = {}
|
data = {}
|
||||||
# S19 handler, try again
|
# S19 handler, try again
|
||||||
@@ -96,9 +98,10 @@ If you are sure you want to use this command please use API.send_command("{item}
|
|||||||
|
|
||||||
async def send_command(
|
async def send_command(
|
||||||
self,
|
self,
|
||||||
command: str,
|
command: str or bytes,
|
||||||
parameters: str or int or bool = None,
|
parameters: str or int or bool = None,
|
||||||
ignore_errors: bool = False,
|
ignore_errors: bool = False,
|
||||||
|
x19_command: bool = False,
|
||||||
) -> dict:
|
) -> dict:
|
||||||
"""Send an API command to the miner and return the result."""
|
"""Send an API command to the miner and return the result."""
|
||||||
try:
|
try:
|
||||||
@@ -143,7 +146,8 @@ If you are sure you want to use this command please use API.send_command("{item}
|
|||||||
# validate the command succeeded
|
# validate the command succeeded
|
||||||
validation = self.validate_command_output(data)
|
validation = self.validate_command_output(data)
|
||||||
if not validation[0]:
|
if not validation[0]:
|
||||||
logging.warning(f"{self.ip}: API Command Error: {validation[1]}")
|
if not x19_command:
|
||||||
|
logging.warning(f"{self.ip}: API Command Error: {validation[1]}")
|
||||||
raise APIError(validation[1])
|
raise APIError(validation[1])
|
||||||
|
|
||||||
return data
|
return data
|
||||||
@@ -167,7 +171,10 @@ If you are sure you want to use this command please use API.send_command("{item}
|
|||||||
return False, data["Msg"]
|
return False, data["Msg"]
|
||||||
else:
|
else:
|
||||||
# make sure the command succeeded
|
# make sure the command succeeded
|
||||||
if data["STATUS"][0]["STATUS"] not in ("S", "I"):
|
if type(data["STATUS"]) == str:
|
||||||
|
if data["STATUS"] in ["RESTART"]:
|
||||||
|
return True, None
|
||||||
|
elif data["STATUS"][0]["STATUS"] not in ("S", "I"):
|
||||||
# this is an error
|
# this is an error
|
||||||
if data["STATUS"][0]["STATUS"] not in ("S", "I"):
|
if data["STATUS"][0]["STATUS"] not in ("S", "I"):
|
||||||
return False, data["STATUS"][0]["Msg"]
|
return False, data["STATUS"][0]["Msg"]
|
||||||
@@ -193,6 +200,12 @@ If you are sure you want to use this command please use API.send_command("{item}
|
|||||||
str_data = str_data.replace("}{", "},{")
|
str_data = str_data.replace("}{", "},{")
|
||||||
# fix an error with a bmminer return having a specific comma that breaks json.loads()
|
# fix an error with a bmminer return having a specific comma that breaks json.loads()
|
||||||
str_data = str_data.replace("[,{", "[{")
|
str_data = str_data.replace("[,{", "[{")
|
||||||
|
# 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:]}"
|
||||||
# parse the json
|
# parse the json
|
||||||
parsed_data = json.loads(str_data)
|
parsed_data = json.loads(str_data)
|
||||||
# handle bad json
|
# handle bad json
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ class BMMinerAPI(BaseMinerAPI):
|
|||||||
:return: A confirmation of adding the pool.
|
:return: A confirmation of adding the pool.
|
||||||
"""
|
"""
|
||||||
return await self.send_command(
|
return await self.send_command(
|
||||||
"addpool", parameters=f"{url}, " f"{username}, " f"{password}"
|
"addpool", parameters=f"{url},{username},{password}"
|
||||||
)
|
)
|
||||||
|
|
||||||
async def poolpriority(self, *n: int) -> dict:
|
async def poolpriority(self, *n: int) -> dict:
|
||||||
@@ -147,7 +147,7 @@ class BMMinerAPI(BaseMinerAPI):
|
|||||||
|
|
||||||
:return: A confirmation of setting pool quota.
|
:return: A confirmation of setting pool quota.
|
||||||
"""
|
"""
|
||||||
return await self.send_command("poolquota", parameters=f"{n}, " f"{q}")
|
return await self.send_command("poolquota", parameters=f"{n},{q}")
|
||||||
|
|
||||||
async def disablepool(self, n: int) -> dict:
|
async def disablepool(self, n: int) -> dict:
|
||||||
"""Disable a pool.
|
"""Disable a pool.
|
||||||
@@ -326,7 +326,7 @@ class BMMinerAPI(BaseMinerAPI):
|
|||||||
|
|
||||||
:return: The results of setting config of name to n.
|
:return: The results of setting config of name to n.
|
||||||
"""
|
"""
|
||||||
return await self.send_command("setconfig", parameters=f"{name}, " f"{n}")
|
return await self.send_command("setconfig", parameters=f"{name},{n}")
|
||||||
|
|
||||||
async def usbstats(self) -> dict:
|
async def usbstats(self) -> dict:
|
||||||
"""Get stats of all USB devices except ztex.
|
"""Get stats of all USB devices except ztex.
|
||||||
@@ -354,11 +354,9 @@ class BMMinerAPI(BaseMinerAPI):
|
|||||||
:return: Confirmation of setting PGA n with opt[,val].
|
:return: Confirmation of setting PGA n with opt[,val].
|
||||||
"""
|
"""
|
||||||
if val:
|
if val:
|
||||||
return await self.send_command(
|
return await self.send_command("pgaset", parameters=f"{n},{opt},{val}")
|
||||||
"pgaset", parameters=f"{n}, " f"{opt}, " f"{val}"
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
return await self.send_command("pgaset", parameters=f"{n}, " f"{opt}")
|
return await self.send_command("pgaset", parameters=f"{n},{opt}")
|
||||||
|
|
||||||
async def zero(self, which: str, summary: bool) -> dict:
|
async def zero(self, which: str, summary: bool) -> dict:
|
||||||
"""Zero a device.
|
"""Zero a device.
|
||||||
@@ -373,7 +371,7 @@ class BMMinerAPI(BaseMinerAPI):
|
|||||||
:return: the STATUS section with info on the zero and optional
|
:return: the STATUS section with info on the zero and optional
|
||||||
summary.
|
summary.
|
||||||
"""
|
"""
|
||||||
return await self.send_command("zero", parameters=f"{which}, {summary}")
|
return await self.send_command("zero", parameters=f"{which},{summary}")
|
||||||
|
|
||||||
async def hotplug(self, n: int) -> dict:
|
async def hotplug(self, n: int) -> dict:
|
||||||
"""Enable hotplug.
|
"""Enable hotplug.
|
||||||
@@ -474,9 +472,9 @@ class BMMinerAPI(BaseMinerAPI):
|
|||||||
:return: Confirmation of setting option opt to value val.
|
:return: Confirmation of setting option opt to value val.
|
||||||
"""
|
"""
|
||||||
if val:
|
if val:
|
||||||
return await self.send_command("ascset", parameters=f"{n}, {opt}, {val}")
|
return await self.send_command("ascset", parameters=f"{n},{opt},{val}")
|
||||||
else:
|
else:
|
||||||
return await self.send_command("ascset", parameters=f"{n}, {opt}")
|
return await self.send_command("ascset", parameters=f"{n},{opt}")
|
||||||
|
|
||||||
async def lcd(self) -> dict:
|
async def lcd(self) -> dict:
|
||||||
"""Get a general all-in-one status summary of the miner.
|
"""Get a general all-in-one status summary of the miner.
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ class BOSMinerAPI(BaseMinerAPI):
|
|||||||
async def addpool(self, url: str, username: str, password: str) -> dict:
|
async def addpool(self, url: str, username: str, password: str) -> dict:
|
||||||
# BOS has not implemented this yet, they will in the future
|
# BOS has not implemented this yet, they will in the future
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
# return await self.send_command("addpool", parameters=f"{url}, {username}, {password}")
|
# return await self.send_command("addpool", parameters=f"{url},{username},{password}")
|
||||||
|
|
||||||
async def removepool(self, n: int) -> dict:
|
async def removepool(self, n: int) -> dict:
|
||||||
# BOS has not implemented this yet, they will in the future
|
# BOS has not implemented this yet, they will in the future
|
||||||
|
|||||||
@@ -163,6 +163,7 @@ class BTMinerAPI(BaseMinerAPI):
|
|||||||
command: str or bytes,
|
command: str or bytes,
|
||||||
parameters: str or int or bool = None,
|
parameters: str or int or bool = None,
|
||||||
ignore_errors: bool = False,
|
ignore_errors: bool = False,
|
||||||
|
**kwargs,
|
||||||
) -> dict:
|
) -> dict:
|
||||||
"""Send a command to the miner API.
|
"""Send a command to the miner API.
|
||||||
|
|
||||||
@@ -434,7 +435,7 @@ class BTMinerAPI(BaseMinerAPI):
|
|||||||
enc_command = create_privileged_cmd(token_data, command)
|
enc_command = create_privileged_cmd(token_data, command)
|
||||||
return await self.send_command(enc_command)
|
return await self.send_command(enc_command)
|
||||||
|
|
||||||
async def update_firmware(self):
|
async def update_firmware(self): # noqa - static
|
||||||
# to be determined if this will be added later
|
# to be determined if this will be added later
|
||||||
# requires a file stream in bytes
|
# requires a file stream in bytes
|
||||||
return NotImplementedError
|
return NotImplementedError
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ class CGMinerAPI(BaseMinerAPI):
|
|||||||
:return: A confirmation of adding the pool.
|
:return: A confirmation of adding the pool.
|
||||||
"""
|
"""
|
||||||
return await self.send_command(
|
return await self.send_command(
|
||||||
"addpool", parameters=f"{url}, " f"{username}, " f"{password}"
|
"addpool", parameters=f"{url},{username},{password}"
|
||||||
)
|
)
|
||||||
|
|
||||||
async def poolpriority(self, *n: int) -> dict:
|
async def poolpriority(self, *n: int) -> dict:
|
||||||
@@ -143,7 +143,7 @@ class CGMinerAPI(BaseMinerAPI):
|
|||||||
|
|
||||||
:return: A confirmation of setting pool quota.
|
:return: A confirmation of setting pool quota.
|
||||||
"""
|
"""
|
||||||
return await self.send_command("poolquota", parameters=f"{n}, " f"{q}")
|
return await self.send_command("poolquota", parameters=f"{n},{q}")
|
||||||
|
|
||||||
async def disablepool(self, n: int) -> dict:
|
async def disablepool(self, n: int) -> dict:
|
||||||
"""Disable a pool.
|
"""Disable a pool.
|
||||||
@@ -322,7 +322,7 @@ class CGMinerAPI(BaseMinerAPI):
|
|||||||
|
|
||||||
:return: The results of setting config of name to n.
|
:return: The results of setting config of name to n.
|
||||||
"""
|
"""
|
||||||
return await self.send_command("setconfig", parameters=f"{name}, " f"{n}")
|
return await self.send_command("setconfig", parameters=f"{name},{n}")
|
||||||
|
|
||||||
async def usbstats(self) -> dict:
|
async def usbstats(self) -> dict:
|
||||||
"""Get stats of all USB devices except ztex.
|
"""Get stats of all USB devices except ztex.
|
||||||
@@ -350,11 +350,9 @@ class CGMinerAPI(BaseMinerAPI):
|
|||||||
:return: Confirmation of setting PGA n with opt[,val].
|
:return: Confirmation of setting PGA n with opt[,val].
|
||||||
"""
|
"""
|
||||||
if val:
|
if val:
|
||||||
return await self.send_command(
|
return await self.send_command("pgaset", parameters=f"{n},{opt},{val}")
|
||||||
"pgaset", parameters=f"{n}, " f"{opt}, " f"{val}"
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
return await self.send_command("pgaset", parameters=f"{n}, " f"{opt}")
|
return await self.send_command("pgaset", parameters=f"{n},{opt}")
|
||||||
|
|
||||||
async def zero(self, which: str, summary: bool) -> dict:
|
async def zero(self, which: str, summary: bool) -> dict:
|
||||||
"""Zero a device.
|
"""Zero a device.
|
||||||
@@ -369,7 +367,7 @@ class CGMinerAPI(BaseMinerAPI):
|
|||||||
:return: the STATUS section with info on the zero and optional
|
:return: the STATUS section with info on the zero and optional
|
||||||
summary.
|
summary.
|
||||||
"""
|
"""
|
||||||
return await self.send_command("zero", parameters=f"{which}, " f"{summary}")
|
return await self.send_command("zero", parameters=f"{which},{summary}")
|
||||||
|
|
||||||
async def hotplug(self, n: int) -> dict:
|
async def hotplug(self, n: int) -> dict:
|
||||||
"""Enable hotplug.
|
"""Enable hotplug.
|
||||||
@@ -470,11 +468,9 @@ class CGMinerAPI(BaseMinerAPI):
|
|||||||
:return: Confirmation of setting option opt to value val.
|
:return: Confirmation of setting option opt to value val.
|
||||||
"""
|
"""
|
||||||
if val:
|
if val:
|
||||||
return await self.send_command(
|
return await self.send_command("ascset", parameters=f"{n},{opt},{val}")
|
||||||
"ascset", parameters=f"{n}, " f"{opt}, " f"{val}"
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
return await self.send_command("ascset", parameters=f"{n}, " f"{opt}")
|
return await self.send_command("ascset", parameters=f"{n},{opt}")
|
||||||
|
|
||||||
async def lcd(self) -> dict:
|
async def lcd(self) -> dict:
|
||||||
"""Get a general all-in-one status summary of the miner.
|
"""Get a general all-in-one status summary of the miner.
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ class UnknownAPI(BaseMinerAPI):
|
|||||||
async def addpool(self, url: str, username: str, password: str) -> dict:
|
async def addpool(self, url: str, username: str, password: str) -> dict:
|
||||||
# BOS has not implemented this yet, they will in the future
|
# BOS has not implemented this yet, they will in the future
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
# return await self.send_command("addpool", parameters=f"{url}, {username}, {password}")
|
# return await self.send_command("addpool", parameters=f"{url},{username},{password}")
|
||||||
|
|
||||||
async def removepool(self, n: int) -> dict:
|
async def removepool(self, n: int) -> dict:
|
||||||
# BOS has not implemented this yet, they will in the future
|
# BOS has not implemented this yet, they will in the future
|
||||||
|
|||||||
149
README.md
149
README.md
@@ -9,7 +9,7 @@ For those of you who aren't comfortable with code and developer tools, there are
|
|||||||
*CFG Util is a GUI for interfacing with the miners easily, it is mostly self-explanatory.*
|
*CFG Util is a GUI for interfacing with the miners easily, it is mostly self-explanatory.*
|
||||||
|
|
||||||
To use CFG Util you have 2 options -
|
To use CFG Util you have 2 options -
|
||||||
1. Run it directly with the file ```config_tool.py``` or import it with ```from cfg_util import main```, then run the ```main()``` function in an asyncio event loop like -
|
1. Run it directly with the file ```config_tool.py``` or import it with ```from cfg_util import main```, then run the ```main()``` function like -
|
||||||
|
|
||||||
```python
|
```python
|
||||||
from tools.cfg_util import main
|
from tools.cfg_util import main
|
||||||
@@ -18,9 +18,9 @@ if __name__ == '__main__':
|
|||||||
main()
|
main()
|
||||||
```
|
```
|
||||||
2. Make a build of the CFG Util for your system using cx_freeze and ```make_cfg_tool_exe.py```
|
2. Make a build of the CFG Util for your system using cx_freeze and ```make_cfg_tool_exe.py```
|
||||||
(Alternatively, you can get a build made by me here -> https://drive.google.com/drive/folders/1nzojuGRu0IszIGpwx7SvG5RlJ2_KXIOv)
|
(Alternatively, you can get a build made by me here -> https://drive.google.com/drive/folders/147vBXbuaX85inataXeSAiKk8IKf-7xtR)
|
||||||
1. Open either Command Prompt on Windows or Terminal on Mac or UNIX.
|
1. Open either Command Prompt on Windows or Terminal on Mac or UNIX.
|
||||||
2. Navigate to this directory, and run ```make_cfg_tool_exe.py build``` on Windows or ```python3 make_cfg_tool_exe.py``` on Mac or UNIX.
|
2. Navigate to this directory, and run ```make_cfg_tool_exe.py build``` on Windows or ```python3 make_cfg_tool_exe.py build``` on Mac or UNIX.
|
||||||
|
|
||||||
### Interfacing with miners programmatically
|
### Interfacing with miners programmatically
|
||||||
<br>
|
<br>
|
||||||
@@ -48,7 +48,6 @@ A basic script to find all miners on the network and get the hashrate from them
|
|||||||
```python
|
```python
|
||||||
import asyncio
|
import asyncio
|
||||||
from network import MinerNetwork
|
from network import MinerNetwork
|
||||||
from tools.cfg_util.func.parse_data import safe_parse_api_data
|
|
||||||
|
|
||||||
|
|
||||||
async def get_hashrate():
|
async def get_hashrate():
|
||||||
@@ -60,18 +59,11 @@ async def get_hashrate():
|
|||||||
# Miner Network scan function returns Miner classes for all miners found
|
# Miner Network scan function returns Miner classes for all miners found
|
||||||
miners = await miner_network.scan_network_for_miners()
|
miners = await miner_network.scan_network_for_miners()
|
||||||
# Each miner will return with its own set of functions, and an API class instance
|
# Each miner will return with its own set of functions, and an API class instance
|
||||||
tasks = [miner.api.summary() for miner in miners]
|
tasks = [miner.get_data() for miner in miners]
|
||||||
# Gather all tasks asynchronously and run them
|
# Gather all tasks asynchronously and run them
|
||||||
data = await asyncio.gather(*tasks)
|
data = await asyncio.gather(*tasks)
|
||||||
parse_tasks = []
|
# now we have a list of MinerData, and can get .hashrate
|
||||||
for item in data:
|
print([item.hashrate for item in data])
|
||||||
# safe_parse_api_data parses the data from a miner API
|
|
||||||
# It will raise an APIError (from API import APIError) if there is a problem
|
|
||||||
parse_tasks.append(safe_parse_api_data(item, 'SUMMARY', 0, 'MHS 5s'))
|
|
||||||
# Gather all tasks asynchronously and run them
|
|
||||||
data = await asyncio.gather(*parse_tasks)
|
|
||||||
# Print a list of all the hashrates
|
|
||||||
print(data)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
@@ -84,7 +76,7 @@ You can also create your own miner without scanning if you know the IP:
|
|||||||
import asyncio
|
import asyncio
|
||||||
import ipaddress
|
import ipaddress
|
||||||
from miners.miner_factory import MinerFactory
|
from miners.miner_factory import MinerFactory
|
||||||
from tools.cfg_util.func.parse_data import safe_parse_api_data
|
|
||||||
|
|
||||||
|
|
||||||
async def get_miner_hashrate(ip: str):
|
async def get_miner_hashrate(ip: str):
|
||||||
@@ -95,77 +87,55 @@ async def get_miner_hashrate(ip: str):
|
|||||||
# Wait for the factory to return the miner
|
# Wait for the factory to return the miner
|
||||||
miner = await miner_factory.get_miner(miner_ip)
|
miner = await miner_factory.get_miner(miner_ip)
|
||||||
# Get the API data
|
# Get the API data
|
||||||
summary = await miner.api.summary()
|
data = await miner.get_data()
|
||||||
# safe_parse_api_data parses the data from a miner API
|
# print out hashrate
|
||||||
# It will raise an APIError (from API import APIError) if there is a problem
|
print(data.hashrate)
|
||||||
data = await safe_parse_api_data(summary, 'SUMMARY', 0, 'MHS 5s')
|
|
||||||
print(data)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
asyncio.new_event_loop().run_until_complete(get_miner_hashrate(str("192.168.1.69")))
|
asyncio.new_event_loop().run_until_complete(
|
||||||
```
|
get_miner_hashrate(str("192.168.1.69")))
|
||||||
|
|
||||||
<br>
|
|
||||||
Or generate a miner directly without the factory:
|
|
||||||
|
|
||||||
```python
|
|
||||||
import asyncio
|
|
||||||
from miners.bosminer import BOSMiner
|
|
||||||
from tools.cfg_util.func.parse_data import safe_parse_api_data
|
|
||||||
|
|
||||||
|
|
||||||
async def get_miner_hashrate(ip: str):
|
|
||||||
# Create a BOSminer miner object
|
|
||||||
miner = BOSMiner(ip)
|
|
||||||
# Get the API data
|
|
||||||
summary = await miner.api.summary()
|
|
||||||
# safe_parse_api_data parses the data from a miner API
|
|
||||||
# It will raise an APIError (from API import APIError) if there is a problem
|
|
||||||
data = await safe_parse_api_data(summary, 'SUMMARY', 0, 'MHS 5s')
|
|
||||||
print(data)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
asyncio.new_event_loop().run_until_complete(get_miner_hashrate(str("192.168.1.69")))
|
|
||||||
```
|
|
||||||
|
|
||||||
<br>
|
|
||||||
Or finally, just get the API directly:
|
|
||||||
|
|
||||||
```python
|
|
||||||
import asyncio
|
|
||||||
from API.bosminer import BOSMinerAPI
|
|
||||||
from tools.cfg_util.func.parse_data import safe_parse_api_data
|
|
||||||
|
|
||||||
|
|
||||||
async def get_miner_hashrate(ip: str):
|
|
||||||
# Create a BOSminerAPI object
|
|
||||||
# Port can be declared manually, if not it defaults to 4028
|
|
||||||
api = BOSMinerAPI(ip, port=4028)
|
|
||||||
# Get the API data
|
|
||||||
summary = await api.summary()
|
|
||||||
# safe_parse_api_data parses the data from a miner API
|
|
||||||
# It will raise an APIError (from API import APIError) if there is a problem
|
|
||||||
data = await safe_parse_api_data(summary, 'SUMMARY', 0, 'MHS 5s')
|
|
||||||
print(data)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
asyncio.new_event_loop().run_until_complete(get_miner_hashrate(str("192.168.1.69")))
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
Now that you know that, lets move on to some common API functions that you might want to use.
|
Now that you know that, lets move on to some common API functions that you might want to use.
|
||||||
|
|
||||||
### Common commands:
|
### Common commands:
|
||||||
|
* Get the data used by the config utility, this includes pool data, wattage use, temperature, hashrate, etc:
|
||||||
|
* All the data from below commands and more are returned from this in a consistent dataclass. Check out the `MinerData` class in `/data/__init__.py` for more information.
|
||||||
|
|
||||||
|
```python
|
||||||
|
import asyncio
|
||||||
|
import ipaddress
|
||||||
|
from miners.miner_factory import MinerFactory
|
||||||
|
|
||||||
|
|
||||||
|
async def get_miner_pool_data(ip: str):
|
||||||
|
# Instantiate a Miner Factory to generate miners from their IP
|
||||||
|
miner_factory = MinerFactory()
|
||||||
|
# Make the string IP into an IP address
|
||||||
|
miner_ip = ipaddress.ip_address(ip)
|
||||||
|
# Wait for the factory to return the miner
|
||||||
|
miner = await miner_factory.get_miner(miner_ip)
|
||||||
|
# Get the data
|
||||||
|
data = await miner.get_data()
|
||||||
|
|
||||||
|
print(data)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
asyncio.new_event_loop().run_until_complete(
|
||||||
|
get_miner_pool_data(str("192.168.1.69")))
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
* Getting pool data:
|
* Getting pool data:
|
||||||
|
|
||||||
```python
|
```python
|
||||||
import asyncio
|
import asyncio
|
||||||
import ipaddress
|
import ipaddress
|
||||||
from miners.miner_factory import MinerFactory
|
from miners.miner_factory import MinerFactory
|
||||||
from tools.cfg_util.func.parse_data import safe_parse_api_data
|
|
||||||
|
|
||||||
|
|
||||||
async def get_miner_pool_data(ip: str):
|
async def get_miner_pool_data(ip: str):
|
||||||
@@ -179,7 +149,7 @@ async def get_miner_pool_data(ip: str):
|
|||||||
pools = await miner.api.pools()
|
pools = await miner.api.pools()
|
||||||
# safe_parse_api_data parses the data from a miner API
|
# safe_parse_api_data parses the data from a miner API
|
||||||
# It will raise an APIError (from API import APIError) if there is a problem
|
# It will raise an APIError (from API import APIError) if there is a problem
|
||||||
data = await safe_parse_api_data(pools, 'POOLS')
|
data = pools["POOLS"]
|
||||||
# parse further from here to get all the pool info you want.
|
# parse further from here to get all the pool info you want.
|
||||||
# each pool is on a different index eg:
|
# each pool is on a different index eg:
|
||||||
# data[0] is pool 1
|
# data[0] is pool 1
|
||||||
@@ -189,7 +159,8 @@ async def get_miner_pool_data(ip: str):
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
asyncio.new_event_loop().run_until_complete(get_miner_pool_data(str("192.168.1.69")))
|
asyncio.new_event_loop().run_until_complete(
|
||||||
|
get_miner_pool_data(str("192.168.1.69")))
|
||||||
```
|
```
|
||||||
|
|
||||||
* Getting temperature data:
|
* Getting temperature data:
|
||||||
@@ -204,7 +175,6 @@ A pretty good example of really trying to make this robust is in ```cfg_util.fun
|
|||||||
import asyncio
|
import asyncio
|
||||||
import ipaddress
|
import ipaddress
|
||||||
from miners.miner_factory import MinerFactory
|
from miners.miner_factory import MinerFactory
|
||||||
from tools.cfg_util.func.parse_data import safe_parse_api_data
|
|
||||||
|
|
||||||
|
|
||||||
async def get_miner_temperature_data(ip: str):
|
async def get_miner_temperature_data(ip: str):
|
||||||
@@ -216,14 +186,14 @@ async def get_miner_temperature_data(ip: str):
|
|||||||
miner = await miner_factory.get_miner(miner_ip)
|
miner = await miner_factory.get_miner(miner_ip)
|
||||||
# Get the API data
|
# Get the API data
|
||||||
summary = await miner.api.summary()
|
summary = await miner.api.summary()
|
||||||
# safe_parse_api_data parses the data from a miner API
|
|
||||||
# It will raise an APIError (from API import APIError) if there is a problem
|
data = summary['SUMMARY'][0]["Temperature"]
|
||||||
data = await safe_parse_api_data(summary, 'SUMMARY', 0, "Temperature")
|
|
||||||
print(data)
|
print(data)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
asyncio.new_event_loop().run_until_complete(get_miner_temperature_data(str("192.168.1.69")))
|
asyncio.new_event_loop().run_until_complete(
|
||||||
|
get_miner_temperature_data(str("192.168.1.69")))
|
||||||
```
|
```
|
||||||
|
|
||||||
* Getting power data:
|
* Getting power data:
|
||||||
@@ -234,10 +204,10 @@ How about data on the power usage of the miner? This one only works for Whatsmi
|
|||||||
import asyncio
|
import asyncio
|
||||||
import ipaddress
|
import ipaddress
|
||||||
from miners.miner_factory import MinerFactory
|
from miners.miner_factory import MinerFactory
|
||||||
from tools.cfg_util.func.parse_data import safe_parse_api_data
|
|
||||||
|
|
||||||
|
|
||||||
async def get_miner_power_data(ip: str):
|
async def get_miner_power_data(ip: str):
|
||||||
|
data = None
|
||||||
# Instantiate a Miner Factory to generate miners from their IP
|
# Instantiate a Miner Factory to generate miners from their IP
|
||||||
miner_factory = MinerFactory()
|
miner_factory = MinerFactory()
|
||||||
# Make the string IP into an IP address
|
# Make the string IP into an IP address
|
||||||
@@ -249,19 +219,21 @@ async def get_miner_power_data(ip: str):
|
|||||||
# send the command
|
# send the command
|
||||||
tunerstatus = await miner.api.tunerstatus()
|
tunerstatus = await miner.api.tunerstatus()
|
||||||
# parse the return
|
# parse the return
|
||||||
data = await safe_parse_api_data(tunerstatus, 'TUNERSTATUS', 0, "PowerLimit")
|
data = tunerstatus['TUNERSTATUS'][0]["PowerLimit"]
|
||||||
else:
|
else:
|
||||||
# send the command
|
# send the command
|
||||||
# whatsminers have the power info in summary
|
# whatsminers have the power info in summary
|
||||||
summary = await miner.api.summary()
|
summary = await miner.api.summary()
|
||||||
# parse the return
|
# parse the return
|
||||||
data = await safe_parse_api_data(summary, 'SUMMARY', 0, "Power")
|
data = summary['SUMMARY'][0]["Power"]
|
||||||
|
|
||||||
print(data)
|
if data:
|
||||||
|
print(data)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
asyncio.new_event_loop().run_until_complete(get_miner_power_data(str("192.168.1.69")))
|
asyncio.new_event_loop().run_until_complete(
|
||||||
|
get_miner_power_data(str("192.168.1.69")))
|
||||||
```
|
```
|
||||||
|
|
||||||
* Multicommands:
|
* Multicommands:
|
||||||
@@ -273,7 +245,7 @@ How about we get the current pool user and hashrate in 1 command?
|
|||||||
import asyncio
|
import asyncio
|
||||||
import ipaddress
|
import ipaddress
|
||||||
from miners.miner_factory import MinerFactory
|
from miners.miner_factory import MinerFactory
|
||||||
from tools.cfg_util.func.parse_data import safe_parse_api_data
|
from tools.cfg_util_old.func.parse_data import safe_parse_api_data
|
||||||
|
|
||||||
|
|
||||||
async def get_miner_hashrate_and_pool(ip: str):
|
async def get_miner_hashrate_and_pool(ip: str):
|
||||||
@@ -286,15 +258,14 @@ async def get_miner_hashrate_and_pool(ip: str):
|
|||||||
# Get the API data
|
# Get the API data
|
||||||
api_data = await miner.api.multicommand("pools", "summary")
|
api_data = await miner.api.multicommand("pools", "summary")
|
||||||
if "pools" in api_data.keys():
|
if "pools" in api_data.keys():
|
||||||
user = await safe_parse_api_data(api_data, "pools", 0, "POOLS", 0, "User")
|
user = api_data["pools"][0]["POOLS"][0]["User"]
|
||||||
print(user)
|
print(user)
|
||||||
if "summary" in api_data.keys():
|
if "summary" in api_data.keys():
|
||||||
hashrate = await safe_parse_api_data(api_data, "summary", 0, "SUMMARY", 0, "MHS av")
|
hashrate = api_data["summary"][0]["SUMMARY"][0]["MHS av"]
|
||||||
print(hashrate)
|
print(hashrate)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
asyncio.new_event_loop().run_until_complete(get_miner_hashrate_and_pool(str("192.168.1.9")))
|
asyncio.new_event_loop().run_until_complete(
|
||||||
|
get_miner_hashrate_and_pool(str("192.168.1.9")))
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +0,0 @@
|
|||||||
from tools.bad_board_util import main
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main()
|
|
||||||
@@ -1,78 +1,366 @@
|
|||||||
"""
|
from dataclasses import dataclass, asdict
|
||||||
SAMPLE CONFIG
|
from typing import List, Literal
|
||||||
-------------------
|
import random
|
||||||
{
|
import string
|
||||||
"format": {
|
|
||||||
"version": "1.2+", # -> (default = "1.2+", str, (bos: format.version))
|
import toml
|
||||||
"model": "Antminer S9", # -> (default = "Antminer S9", str, (bos: format.model))
|
import yaml
|
||||||
"generator": "upstream_config_util", # -> (hidden, always = "upstream_config_util", str, (bos: format.generator))
|
import json
|
||||||
"timestamp": 1606842000, # -> (hidden, always = int(time.time()) (current unix time), int, (bos: format.timestamp))
|
import time
|
||||||
},
|
|
||||||
"temperature": {
|
|
||||||
"mode": "auto", # -> (default = "auto", str["auto", "manual", "disabled"], (bos: temp_control.mode))
|
@dataclass
|
||||||
"target": 70.0, # -> (default = 70.0, float, (bos: temp_control.target_temp))
|
class _Pool:
|
||||||
"hot": 80.0, # -> (default = 80.0, float, (bos: temp_control.hot_temp))
|
"""A dataclass for pool information.
|
||||||
"danger": 90.0, # -> (default = 90.0, float, (bos: temp_control.dangerous_temp))
|
|
||||||
},
|
:param url: URL of the pool.
|
||||||
"fans": { # -> (optional, required if temperature["mode"] == "disabled", (bos: fan_control))
|
:param username: Username on the pool.
|
||||||
"min_fans": 1, # -> (default = 1, int, (bos: fan_control.min_fans))
|
:param password: Worker password on the pool.
|
||||||
"speed": 100, # -> (default = 100, 0 < int < 100, (bos: fan_control.speed))
|
"""
|
||||||
},
|
|
||||||
"asicboost": True, # -> (default = True, bool, (bos : hash_chain_global.asic_boost))
|
url: str = ""
|
||||||
"pool_groups": [
|
username: str = ""
|
||||||
{
|
password: str = ""
|
||||||
"group_name": "Upstream", # -> (default = "group_{index}" (group_0), str, (bos: group.[index].name))
|
|
||||||
"quota": 1, # -> (default = 1, int, (bos: group.[index].quota))
|
def from_dict(self, data: dict):
|
||||||
"pools": [
|
"""Convert raw pool data as a dict to usable data and save it to this class.
|
||||||
{
|
|
||||||
"url": "stratum+tcp://stratum.slushpool.com:3333", # -> (str, (bos: group.[index].pool.[index].url))
|
:param data: The raw config data to convert.
|
||||||
"username": "UpstreamDataInc.test", # -> (str, (bos: group.[index].pool.[index].user))
|
"""
|
||||||
"password": "123", # -> (str, (bos: group.[index].pool.[index].password))
|
for key in data.keys():
|
||||||
},
|
if key == "url":
|
||||||
{
|
self.url = data[key]
|
||||||
"url": "stratum+tcp://us-east.stratum.slushpool.com:3333", # -> (str, (bos: group.[index].pool.[index].url))
|
if key in ["user", "username"]:
|
||||||
"username": "UpstreamDataInc.test", # -> (str, (bos: group.[index].pool.[index].user))
|
self.username = data[key]
|
||||||
"password": "123", # -> (str, (bos: group.[index].pool.[index].password))
|
if key in ["pass", "password"]:
|
||||||
},
|
self.password = data[key]
|
||||||
{
|
return self
|
||||||
"url": "stratum+tcp://ca.stratum.slushpool.com:3333", # -> (str, (bos: group.[index].pool.[index].url))
|
|
||||||
"username": "UpstreamDataInc.test", # -> (str, (bos: group.[index].pool.[index].user))
|
def as_x19(self, user_suffix: str = None):
|
||||||
"password": "123", # -> (str, (bos: group.[index].pool.[index].password))
|
"""Convert the data in this class to a dict usable by an X19 device.
|
||||||
},
|
|
||||||
|
:param user_suffix: The suffix to append to username.
|
||||||
|
"""
|
||||||
|
username = self.username
|
||||||
|
if user_suffix:
|
||||||
|
username = f"{username}{user_suffix}"
|
||||||
|
|
||||||
|
pool = {"url": self.url, "user": username, "pass": self.password}
|
||||||
|
return pool
|
||||||
|
|
||||||
|
def as_avalon(self, user_suffix: str = None):
|
||||||
|
username = self.username
|
||||||
|
if user_suffix:
|
||||||
|
username = f"{username}{user_suffix}"
|
||||||
|
|
||||||
|
pool = ",".join([self.url, username, self.password])
|
||||||
|
return pool
|
||||||
|
|
||||||
|
def as_bos(self, user_suffix: str = None):
|
||||||
|
"""Convert the data in this class to a dict usable by an BOSMiner device.
|
||||||
|
|
||||||
|
:param user_suffix: The suffix to append to username.
|
||||||
|
"""
|
||||||
|
username = self.username
|
||||||
|
if user_suffix:
|
||||||
|
username = f"{username}{user_suffix}"
|
||||||
|
|
||||||
|
pool = {"url": self.url, "user": username, "password": self.password}
|
||||||
|
return pool
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class _PoolGroup:
|
||||||
|
"""A dataclass for pool group information.
|
||||||
|
|
||||||
|
:param quota: The group quota.
|
||||||
|
:param group_name: The name of the pool group.
|
||||||
|
:param pools: A list of pools in this group.
|
||||||
|
"""
|
||||||
|
|
||||||
|
quota: int = 1
|
||||||
|
group_name: str = None
|
||||||
|
pools: List[_Pool] = None
|
||||||
|
|
||||||
|
def __post_init__(self):
|
||||||
|
if not self.group_name:
|
||||||
|
self.group_name = "".join(
|
||||||
|
random.choice(string.ascii_uppercase + string.digits) for _ in range(6)
|
||||||
|
) # generate random pool group name in case it isn't set
|
||||||
|
|
||||||
|
def from_dict(self, data: dict):
|
||||||
|
"""Convert raw pool group data as a dict to usable data and save it to this class.
|
||||||
|
|
||||||
|
:param data: The raw config data to convert.
|
||||||
|
"""
|
||||||
|
pools = []
|
||||||
|
for key in data.keys():
|
||||||
|
if key in ["name", "group_name"]:
|
||||||
|
self.group_name = data[key]
|
||||||
|
if key == "quota":
|
||||||
|
self.quota = data[key]
|
||||||
|
if key in ["pools", "pool"]:
|
||||||
|
for pool in data[key]:
|
||||||
|
pools.append(_Pool().from_dict(pool))
|
||||||
|
self.pools = pools
|
||||||
|
return self
|
||||||
|
|
||||||
|
def as_x19(self, user_suffix: str = None):
|
||||||
|
"""Convert the data in this class to a dict usable by an X19 device.
|
||||||
|
|
||||||
|
:param user_suffix: The suffix to append to username.
|
||||||
|
"""
|
||||||
|
pools = []
|
||||||
|
for pool in self.pools[:3]:
|
||||||
|
pools.append(pool.as_x19(user_suffix=user_suffix))
|
||||||
|
return pools
|
||||||
|
|
||||||
|
def as_avalon(self, user_suffix: str = None):
|
||||||
|
pool = self.pools[0].as_avalon(user_suffix=user_suffix)
|
||||||
|
return pool
|
||||||
|
|
||||||
|
def as_bos(self, user_suffix: str = None):
|
||||||
|
"""Convert the data in this class to a dict usable by an BOSMiner device.
|
||||||
|
|
||||||
|
:param user_suffix: The suffix to append to username.
|
||||||
|
"""
|
||||||
|
group = {
|
||||||
|
"name": self.group_name,
|
||||||
|
"quota": self.quota,
|
||||||
|
"pool": [pool.as_bos(user_suffix=user_suffix) for pool in self.pools],
|
||||||
|
}
|
||||||
|
return group
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class MinerConfig:
|
||||||
|
"""A dataclass for miner configuration information.
|
||||||
|
|
||||||
|
:param pool_groups: A list of pool groups in this config.
|
||||||
|
:param temp_mode: The temperature control mode.
|
||||||
|
:param temp_target: The target temp.
|
||||||
|
:param temp_hot: The hot temp (100% fans).
|
||||||
|
:param temp_dangerous: The dangerous temp (shutdown).
|
||||||
|
:param minimum_fans: The minimum numbers of fans to run the miner.
|
||||||
|
:param fan_speed: Manual fan speed to run the fan at (only if temp_mode == "manual").
|
||||||
|
:param asicboost: Whether or not to enable asicboost.
|
||||||
|
:param autotuning_enabled: Whether or not to enable autotuning.
|
||||||
|
:param autotuning_wattage: The wattage to use when autotuning.
|
||||||
|
:param dps_enabled: Whether or not to enable dynamic power scaling.
|
||||||
|
:param dps_power_step: The amount of power to reduce autotuning by when the miner reaches dangerous temp.
|
||||||
|
:param dps_min_power: The minimum power to reduce autotuning to.
|
||||||
|
:param dps_shutdown_enabled: Whether or not to shutdown the miner when `dps_min_power` is reached.
|
||||||
|
:param dps_shutdown_duration: The amount of time to shutdown for (in hours).
|
||||||
|
"""
|
||||||
|
|
||||||
|
pool_groups: List[_PoolGroup] = None
|
||||||
|
|
||||||
|
temp_mode: Literal["auto", "manual", "disabled"] = "auto"
|
||||||
|
temp_target: float = 70.0
|
||||||
|
temp_hot: float = 80.0
|
||||||
|
temp_dangerous: float = 10.0
|
||||||
|
|
||||||
|
minimum_fans: int = None
|
||||||
|
fan_speed: Literal[tuple(range(101))] = None # noqa - Ignore weird Literal usage
|
||||||
|
|
||||||
|
asicboost: bool = None
|
||||||
|
|
||||||
|
autotuning_enabled: bool = True
|
||||||
|
autotuning_wattage: int = 900
|
||||||
|
|
||||||
|
dps_enabled: bool = None
|
||||||
|
dps_power_step: int = None
|
||||||
|
dps_min_power: int = None
|
||||||
|
dps_shutdown_enabled: bool = None
|
||||||
|
dps_shutdown_duration: float = None
|
||||||
|
|
||||||
|
def as_dict(self):
|
||||||
|
"""Convert the data in this class to a dict."""
|
||||||
|
|
||||||
|
data_dict = asdict(self)
|
||||||
|
for key in asdict(self).keys():
|
||||||
|
if data_dict[key] is None:
|
||||||
|
del data_dict[key]
|
||||||
|
return data_dict
|
||||||
|
|
||||||
|
def as_toml(self):
|
||||||
|
"""Convert the data in this class to toml."""
|
||||||
|
return toml.dumps(self.as_dict())
|
||||||
|
|
||||||
|
def as_yaml(self):
|
||||||
|
"""Convert the data in this class to yaml."""
|
||||||
|
return yaml.dump(self.as_dict(), sort_keys=False)
|
||||||
|
|
||||||
|
def from_raw(self, data: dict):
|
||||||
|
"""Convert raw config data as a dict to usable data and save it to this class.
|
||||||
|
|
||||||
|
:param data: The raw config data to convert.
|
||||||
|
"""
|
||||||
|
pool_groups = []
|
||||||
|
for key in data.keys():
|
||||||
|
if key == "pools":
|
||||||
|
pool_groups.append(_PoolGroup().from_dict({"pools": data[key]}))
|
||||||
|
elif key == "group":
|
||||||
|
for group in data[key]:
|
||||||
|
pool_groups.append(_PoolGroup().from_dict(group))
|
||||||
|
|
||||||
|
if key == "bitmain-fan-ctrl":
|
||||||
|
if data[key]:
|
||||||
|
self.temp_mode = "manual"
|
||||||
|
if data.get("bitmain-fan-pwm"):
|
||||||
|
self.fan_speed = int(data["bitmain-fan-pwm"])
|
||||||
|
elif key == "fan_control":
|
||||||
|
for _key in data[key].keys():
|
||||||
|
if _key == "min_fans":
|
||||||
|
self.minimum_fans = data[key][_key]
|
||||||
|
elif _key == "speed":
|
||||||
|
self.fan_speed = data[key][_key]
|
||||||
|
elif key == "temp_control":
|
||||||
|
for _key in data[key].keys():
|
||||||
|
if _key == "mode":
|
||||||
|
self.temp_mode = data[key][_key]
|
||||||
|
elif _key == "target_temp":
|
||||||
|
self.temp_target = data[key][_key]
|
||||||
|
elif _key == "hot_temp":
|
||||||
|
self.temp_hot = data[key][_key]
|
||||||
|
elif _key == "dangerous_temp":
|
||||||
|
self.temp_dangerous = data[key][_key]
|
||||||
|
|
||||||
|
if key == "hash_chain_global":
|
||||||
|
if data[key].get("asic_boost"):
|
||||||
|
self.asicboost = data[key]["asic_boost"]
|
||||||
|
|
||||||
|
if key == "autotuning":
|
||||||
|
for _key in data[key].keys():
|
||||||
|
if _key == "enabled":
|
||||||
|
self.autotuning_enabled = data[key][_key]
|
||||||
|
elif _key == "psu_power_limit":
|
||||||
|
self.autotuning_wattage = data[key][_key]
|
||||||
|
|
||||||
|
if key == "power_scaling":
|
||||||
|
for _key in data[key].keys():
|
||||||
|
if _key == "enabled":
|
||||||
|
self.dps_enabled = data[key][_key]
|
||||||
|
elif _key == "power_step":
|
||||||
|
self.dps_power_step = data[key][_key]
|
||||||
|
elif _key == "min_psu_power_limit":
|
||||||
|
self.dps_min_power = data[key][_key]
|
||||||
|
elif _key == "shutdown_enabled":
|
||||||
|
self.dps_shutdown_enabled = data[key][_key]
|
||||||
|
elif _key == "shutdown_duration":
|
||||||
|
self.dps_shutdown_duration = data[key][_key]
|
||||||
|
|
||||||
|
self.pool_groups = pool_groups
|
||||||
|
return self
|
||||||
|
|
||||||
|
def from_dict(self, data: dict):
|
||||||
|
"""Convert an output dict of this class back into usable data and save it to this class.
|
||||||
|
|
||||||
|
:param data: The raw config data to convert.
|
||||||
|
"""
|
||||||
|
pool_groups = []
|
||||||
|
for group in data["pool_groups"]:
|
||||||
|
pool_groups.append(_PoolGroup().from_dict(group))
|
||||||
|
for key in data.keys():
|
||||||
|
if getattr(self, key) and not key == "pool_groups":
|
||||||
|
setattr(self, key, data[key])
|
||||||
|
self.pool_groups = pool_groups
|
||||||
|
return self
|
||||||
|
|
||||||
|
def from_toml(self, data: str):
|
||||||
|
"""Convert output toml of this class back into usable data and save it to this class.
|
||||||
|
|
||||||
|
:param data: The raw config data to convert.
|
||||||
|
"""
|
||||||
|
return self.from_dict(toml.loads(data))
|
||||||
|
|
||||||
|
def from_yaml(self, data: str):
|
||||||
|
"""Convert output yaml of this class back into usable data and save it to this class.
|
||||||
|
|
||||||
|
:param data: The raw config data to convert.
|
||||||
|
"""
|
||||||
|
return self.from_dict(yaml.load(data, Loader=yaml.SafeLoader))
|
||||||
|
|
||||||
|
def as_x19(self, user_suffix: str = None) -> str:
|
||||||
|
"""Convert the data in this class to a config usable by an X19 device.
|
||||||
|
|
||||||
|
:param user_suffix: The suffix to append to username.
|
||||||
|
"""
|
||||||
|
cfg = {
|
||||||
|
"pools": self.pool_groups[0].as_x19(user_suffix=user_suffix),
|
||||||
|
"bitmain-fan-ctrl": False,
|
||||||
|
"bitmain-fan-pwn": 100,
|
||||||
|
}
|
||||||
|
|
||||||
|
if not self.temp_mode == "auto":
|
||||||
|
cfg["bitmain-fan-ctrl"] = True
|
||||||
|
|
||||||
|
if self.fan_speed:
|
||||||
|
cfg["bitmain-fan-ctrl"] = str(self.fan_speed)
|
||||||
|
|
||||||
|
return json.dumps(cfg)
|
||||||
|
|
||||||
|
def as_avalon(self, user_suffix: str = None) -> str:
|
||||||
|
cfg = self.pool_groups[0].as_avalon()
|
||||||
|
return cfg
|
||||||
|
|
||||||
|
def as_bos(self, model: str = "S9", user_suffix: str = None) -> str:
|
||||||
|
"""Convert the data in this class to a config usable by an BOSMiner device.
|
||||||
|
|
||||||
|
:param model: The model of the miner to be used in the format portion of the config.
|
||||||
|
:param user_suffix: The suffix to append to username.
|
||||||
|
"""
|
||||||
|
cfg = {
|
||||||
|
"format": {
|
||||||
|
"version": "1.2+",
|
||||||
|
"model": f"Antminer {model}",
|
||||||
|
"generator": "Upstream Config Utility",
|
||||||
|
"timestamp": int(time.time()),
|
||||||
|
},
|
||||||
|
"group": [
|
||||||
|
group.as_bos(user_suffix=user_suffix) for group in self.pool_groups
|
||||||
|
],
|
||||||
|
"temp_control": {
|
||||||
|
"mode": self.temp_mode,
|
||||||
|
"target_temp": self.temp_target,
|
||||||
|
"hot_temp": self.temp_hot,
|
||||||
|
"dangerous_temp": self.temp_dangerous,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
if self.autotuning_enabled or self.autotuning_wattage:
|
||||||
|
cfg["autotuning"] = {}
|
||||||
|
if self.autotuning_enabled:
|
||||||
|
cfg["autotuning"]["enabled"] = self.autotuning_enabled
|
||||||
|
if self.autotuning_wattage:
|
||||||
|
cfg["autotuning"]["psu_power_limit"] = self.autotuning_wattage
|
||||||
|
|
||||||
|
if self.asicboost:
|
||||||
|
cfg["hash_chain_global"] = {}
|
||||||
|
cfg["hash_chain_global"]["asic_boost"] = self.asicboost
|
||||||
|
|
||||||
|
if any(
|
||||||
|
[
|
||||||
|
getattr(self, item)
|
||||||
|
for item in [
|
||||||
|
"dps_enabled",
|
||||||
|
"dps_power_step",
|
||||||
|
"dps_min_power",
|
||||||
|
"dps_shutdown_enabled",
|
||||||
|
"dps_shutdown_duration",
|
||||||
|
]
|
||||||
]
|
]
|
||||||
},
|
):
|
||||||
{
|
cfg["power_scaling"] = {}
|
||||||
"group_name": "Upstream2", # -> (default = "group_{index}" (group_1), str, (bos: group.[index].name))
|
if self.dps_enabled:
|
||||||
"quota": 4, # -> (default = 1, int, (bos: group.[index].quota))
|
cfg["power_scaling"]["enabled"] = self.dps_enabled
|
||||||
"pools": [
|
if self.dps_power_step:
|
||||||
{
|
cfg["power_scaling"]["power_step"] = self.dps_power_step
|
||||||
"url": "stratum+tcp://stratum.slushpool.com:3333", # -> (str, (bos: group.[index].pool.[index].url))
|
if self.dps_min_power:
|
||||||
"username": "UpstreamDataTesting.test", # -> (str, (bos: group.[index].pool.[index].user))
|
cfg["power_scaling"]["min_psu_power_limit"] = self.dps_min_power
|
||||||
"password": "123", # -> (str, (bos: group.[index].pool.[index].password))
|
if self.dps_shutdown_enabled:
|
||||||
},
|
cfg["power_scaling"]["shutdown_enabled"] = self.dps_shutdown_enabled
|
||||||
{
|
if self.dps_shutdown_duration:
|
||||||
"url": "stratum+tcp://us-east.stratum.slushpool.com:3333", # -> (str, (bos: group.[index].pool.[index].url))
|
cfg["power_scaling"]["shutdown_duration"] = self.dps_shutdown_duration
|
||||||
"username": "UpstreamDataTesting.test", # -> (str, (bos: group.[index].pool.[index].user))
|
|
||||||
"password": "123", # -> (str, (bos: group.[index].pool.[index].password))
|
return toml.dumps(cfg)
|
||||||
},
|
|
||||||
{
|
|
||||||
"url": "stratum+tcp://ca.stratum.slushpool.com:3333", # -> (str, (bos: group.[index].pool.[index].url))
|
|
||||||
"username": "UpstreamDataTesting.test", # -> (str, (bos: group.[index].pool.[index].user))
|
|
||||||
"password": "123", # -> (str, (bos: group.[index].pool.[index].password))
|
|
||||||
},
|
|
||||||
]
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"autotuning": {
|
|
||||||
"enabled": True, # -> (default = True, bool), (bos: autotuning.enabled)
|
|
||||||
"wattage": 900, # -> (default = 900, int, (bos: autotuning.psu_power_limit))
|
|
||||||
},
|
|
||||||
"power_scaling": {
|
|
||||||
"enabled": False, # -> (default = False, bool, (bos: power_scaling.enabled))
|
|
||||||
"power_step": 100, # -> (default = 100, int, (bos: power_scaling.power_step))
|
|
||||||
"min_psu_power_limit": 800, # -> (default = 800, int, (bos: power_scaling.min_psu_power_limit))
|
|
||||||
"shutdown_enabled": True, # -> (default = False, bool, (bos: power_scaling.shutdown_enabled))
|
|
||||||
"shutdown_duration": 3.0, # -> (default = 3.0, float, (bos: power_scaling.shutdown_duration))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
"""
|
|
||||||
|
|||||||
221
config/bos.py
221
config/bos.py
@@ -1,221 +0,0 @@
|
|||||||
import time
|
|
||||||
import yaml
|
|
||||||
import toml
|
|
||||||
|
|
||||||
|
|
||||||
async def bos_config_convert(config: dict):
|
|
||||||
out_config = {}
|
|
||||||
for opt in config:
|
|
||||||
if opt == "format":
|
|
||||||
out_config["format"] = config[opt]
|
|
||||||
out_config["format"]["generator"] = "upstream_config_util"
|
|
||||||
out_config["format"]["timestamp"] = int(time.time())
|
|
||||||
elif opt == "temp_control":
|
|
||||||
out_config["temperature"] = {}
|
|
||||||
if "mode" in config[opt].keys():
|
|
||||||
out_config["temperature"]["mode"] = config[opt]["mode"]
|
|
||||||
else:
|
|
||||||
out_config["temperature"]["mode"] = "auto"
|
|
||||||
|
|
||||||
if "target_temp" in config[opt].keys():
|
|
||||||
out_config["temperature"]["target"] = config[opt]["target_temp"]
|
|
||||||
else:
|
|
||||||
out_config["temperature"]["target"] = 70.0
|
|
||||||
|
|
||||||
if "hot_temp" in config[opt].keys():
|
|
||||||
out_config["temperature"]["hot"] = config[opt]["hot_temp"]
|
|
||||||
else:
|
|
||||||
out_config["temperature"]["hot"] = 80.0
|
|
||||||
|
|
||||||
if "dangerous_temp" in config[opt].keys():
|
|
||||||
out_config["temperature"]["danger"] = config[opt]["dangerous_temp"]
|
|
||||||
else:
|
|
||||||
out_config["temperature"]["danger"] = 90.0
|
|
||||||
elif opt == "fan_control":
|
|
||||||
out_config["fans"] = {}
|
|
||||||
if "min_fans" in config[opt].keys():
|
|
||||||
out_config["fans"]["min_fans"] = config[opt]["min_fans"]
|
|
||||||
else:
|
|
||||||
out_config["fans"]["min_fans"] = 1
|
|
||||||
if "speed" in config[opt].keys():
|
|
||||||
out_config["fans"]["speed"] = config[opt]["speed"]
|
|
||||||
else:
|
|
||||||
out_config["fans"]["speed"] = 100
|
|
||||||
elif opt == "group":
|
|
||||||
out_config["pool_groups"] = [{} for _item in range(len(config[opt]))]
|
|
||||||
for idx in range(len(config[opt])):
|
|
||||||
out_config["pool_groups"][idx]["pools"] = []
|
|
||||||
out_config["pool_groups"][idx] = {}
|
|
||||||
if "name" in config[opt][idx].keys():
|
|
||||||
out_config["pool_groups"][idx]["group_name"] = config[opt][idx][
|
|
||||||
"name"
|
|
||||||
]
|
|
||||||
else:
|
|
||||||
out_config["pool_groups"][idx]["group_name"] = f"group_{idx}"
|
|
||||||
if "quota" in config[opt][idx].keys():
|
|
||||||
out_config["pool_groups"][idx]["quota"] = config[opt][idx]["quota"]
|
|
||||||
else:
|
|
||||||
out_config["pool_groups"][idx]["quota"] = 1
|
|
||||||
out_config["pool_groups"][idx]["pools"] = [
|
|
||||||
{} for _item in range(len(config[opt][idx]["pool"]))
|
|
||||||
]
|
|
||||||
for pool_idx in range(len(config[opt][idx]["pool"])):
|
|
||||||
out_config["pool_groups"][idx]["pools"][pool_idx]["url"] = config[
|
|
||||||
opt
|
|
||||||
][idx]["pool"][pool_idx]["url"]
|
|
||||||
out_config["pool_groups"][idx]["pools"][pool_idx][
|
|
||||||
"username"
|
|
||||||
] = config[opt][idx]["pool"][pool_idx]["user"]
|
|
||||||
out_config["pool_groups"][idx]["pools"][pool_idx][
|
|
||||||
"password"
|
|
||||||
] = config[opt][idx]["pool"][pool_idx]["password"]
|
|
||||||
elif opt == "autotuning":
|
|
||||||
out_config["autotuning"] = {}
|
|
||||||
if "enabled" in config[opt].keys():
|
|
||||||
out_config["autotuning"]["enabled"] = config[opt]["enabled"]
|
|
||||||
else:
|
|
||||||
out_config["autotuning"]["enabled"] = True
|
|
||||||
if "psu_power_limit" in config[opt].keys():
|
|
||||||
out_config["autotuning"]["wattage"] = config[opt]["psu_power_limit"]
|
|
||||||
else:
|
|
||||||
out_config["autotuning"]["wattage"] = 900
|
|
||||||
elif opt == "power_scaling":
|
|
||||||
out_config["power_scaling"] = {}
|
|
||||||
if "enabled" in config[opt].keys():
|
|
||||||
out_config["power_scaling"]["enabled"] = config[opt]["enabled"]
|
|
||||||
else:
|
|
||||||
out_config["power_scaling"]["enabled"] = False
|
|
||||||
if "power_step" in config[opt].keys():
|
|
||||||
out_config["power_scaling"]["power_step"] = config[opt]["power_step"]
|
|
||||||
else:
|
|
||||||
out_config["power_scaling"]["power_step"] = 100
|
|
||||||
if "min_psu_power_limit" in config[opt].keys():
|
|
||||||
out_config["power_scaling"]["min_psu_power_limit"] = config[opt][
|
|
||||||
"min_psu_power_limit"
|
|
||||||
]
|
|
||||||
else:
|
|
||||||
out_config["power_scaling"]["min_psu_power_limit"] = 800
|
|
||||||
if "shutdown_enabled" in config[opt].keys():
|
|
||||||
out_config["power_scaling"]["shutdown_enabled"] = config[opt][
|
|
||||||
"shutdown_enabled"
|
|
||||||
]
|
|
||||||
else:
|
|
||||||
out_config["power_scaling"]["shutdown_enabled"] = False
|
|
||||||
if "shutdown_duration" in config[opt].keys():
|
|
||||||
out_config["power_scaling"]["shutdown_duration"] = config[opt][
|
|
||||||
"shutdown_duration"
|
|
||||||
]
|
|
||||||
else:
|
|
||||||
out_config["power_scaling"]["shutdown_duration"] = 3.0
|
|
||||||
return yaml.dump(out_config, sort_keys=False)
|
|
||||||
|
|
||||||
|
|
||||||
async def general_config_convert_bos(yaml_config, user_suffix: str = None):
|
|
||||||
config = yaml.load(yaml_config, Loader=yaml.SafeLoader)
|
|
||||||
out_config = {}
|
|
||||||
for opt in config:
|
|
||||||
if opt == "format":
|
|
||||||
out_config["format"] = config[opt]
|
|
||||||
out_config["format"]["generator"] = "upstream_config_util"
|
|
||||||
out_config["format"]["timestamp"] = int(time.time())
|
|
||||||
elif opt == "temperature":
|
|
||||||
out_config["temp_control"] = {}
|
|
||||||
if "mode" in config[opt].keys():
|
|
||||||
out_config["temp_control"]["mode"] = config[opt]["mode"]
|
|
||||||
else:
|
|
||||||
out_config["temp_control"]["mode"] = "auto"
|
|
||||||
|
|
||||||
if "target" in config[opt].keys():
|
|
||||||
out_config["temp_control"]["target_temp"] = config[opt]["target"]
|
|
||||||
else:
|
|
||||||
out_config["temp_control"]["target_temp"] = 70.0
|
|
||||||
|
|
||||||
if "hot" in config[opt].keys():
|
|
||||||
out_config["temp_control"]["hot_temp"] = config[opt]["hot"]
|
|
||||||
else:
|
|
||||||
out_config["temp_control"]["hot_temp"] = 80.0
|
|
||||||
|
|
||||||
if "danger" in config[opt].keys():
|
|
||||||
out_config["temp_control"]["dangerous_temp"] = config[opt]["danger"]
|
|
||||||
else:
|
|
||||||
out_config["temp_control"]["dangerous_temp"] = 90.0
|
|
||||||
elif opt == "fans":
|
|
||||||
out_config["fan_control"] = {}
|
|
||||||
if "min_fans" in config[opt].keys():
|
|
||||||
out_config["fan_control"]["min_fans"] = config[opt]["min_fans"]
|
|
||||||
else:
|
|
||||||
out_config["fan_control"]["min_fans"] = 1
|
|
||||||
if "speed" in config[opt].keys():
|
|
||||||
out_config["fan_control"]["speed"] = config[opt]["speed"]
|
|
||||||
else:
|
|
||||||
out_config["fan_control"]["speed"] = 100
|
|
||||||
elif opt == "pool_groups":
|
|
||||||
out_config["group"] = [{} for _item in range(len(config[opt]))]
|
|
||||||
for idx in range(len(config[opt])):
|
|
||||||
out_config["group"][idx]["pools"] = []
|
|
||||||
out_config["group"][idx] = {}
|
|
||||||
if "group_name" in config[opt][idx].keys():
|
|
||||||
out_config["group"][idx]["name"] = config[opt][idx]["group_name"]
|
|
||||||
else:
|
|
||||||
out_config["group"][idx]["name"] = f"group_{idx}"
|
|
||||||
if "quota" in config[opt][idx].keys():
|
|
||||||
out_config["group"][idx]["quota"] = config[opt][idx]["quota"]
|
|
||||||
else:
|
|
||||||
out_config["group"][idx]["quota"] = 1
|
|
||||||
out_config["group"][idx]["pool"] = [
|
|
||||||
{} for _item in range(len(config[opt][idx]["pools"]))
|
|
||||||
]
|
|
||||||
for pool_idx in range(len(config[opt][idx]["pools"])):
|
|
||||||
out_config["group"][idx]["pool"][pool_idx]["url"] = config[opt][
|
|
||||||
idx
|
|
||||||
]["pools"][pool_idx]["url"]
|
|
||||||
username = config[opt][idx]["pools"][pool_idx]["username"]
|
|
||||||
if user_suffix:
|
|
||||||
if "." in username:
|
|
||||||
username = f"{username}x{user_suffix}"
|
|
||||||
else:
|
|
||||||
username = f"{username}.{user_suffix}"
|
|
||||||
out_config["group"][idx]["pool"][pool_idx]["user"] = username
|
|
||||||
|
|
||||||
out_config["group"][idx]["pool"][pool_idx]["password"] = config[
|
|
||||||
opt
|
|
||||||
][idx]["pools"][pool_idx]["password"]
|
|
||||||
elif opt == "autotuning":
|
|
||||||
out_config["autotuning"] = {}
|
|
||||||
if "enabled" in config[opt].keys():
|
|
||||||
out_config["autotuning"]["enabled"] = config[opt]["enabled"]
|
|
||||||
else:
|
|
||||||
out_config["autotuning"]["enabled"] = True
|
|
||||||
if "wattage" in config[opt].keys():
|
|
||||||
out_config["autotuning"]["psu_power_limit"] = config[opt]["wattage"]
|
|
||||||
else:
|
|
||||||
out_config["autotuning"]["psu_power_limit"] = 900
|
|
||||||
elif opt == "power_scaling":
|
|
||||||
out_config["power_scaling"] = {}
|
|
||||||
if "enabled" in config[opt].keys():
|
|
||||||
out_config["power_scaling"]["enabled"] = config[opt]["enabled"]
|
|
||||||
else:
|
|
||||||
out_config["power_scaling"]["enabled"] = False
|
|
||||||
if "power_step" in config[opt].keys():
|
|
||||||
out_config["power_scaling"]["power_step"] = config[opt]["power_step"]
|
|
||||||
else:
|
|
||||||
out_config["power_scaling"]["power_step"] = 100
|
|
||||||
if "min_psu_power_limit" in config[opt].keys():
|
|
||||||
out_config["power_scaling"]["min_psu_power_limit"] = config[opt][
|
|
||||||
"min_psu_power_limit"
|
|
||||||
]
|
|
||||||
else:
|
|
||||||
out_config["power_scaling"]["min_psu_power_limit"] = 800
|
|
||||||
if "shutdown_enabled" in config[opt].keys():
|
|
||||||
out_config["power_scaling"]["shutdown_enabled"] = config[opt][
|
|
||||||
"shutdown_enabled"
|
|
||||||
]
|
|
||||||
else:
|
|
||||||
out_config["power_scaling"]["shutdown_enabled"] = False
|
|
||||||
if "shutdown_duration" in config[opt].keys():
|
|
||||||
out_config["power_scaling"]["shutdown_duration"] = config[opt][
|
|
||||||
"shutdown_duration"
|
|
||||||
]
|
|
||||||
else:
|
|
||||||
out_config["power_scaling"]["shutdown_duration"] = 3.0
|
|
||||||
return out_config
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
|
|
||||||
config cgminer 'default'
|
|
||||||
option pool1pw 'x'
|
|
||||||
option pool2pw 'x'
|
|
||||||
option pool3pw 'x'
|
|
||||||
option voltage_level_offset '0'
|
|
||||||
option fan '10'
|
|
||||||
option api_allow 'W:0/0'
|
|
||||||
option power_mode 'balance'
|
|
||||||
option pool1url 'stratum+tcp://ca.stratum.slushpool.com:3333'
|
|
||||||
option pool1user 'poolacct.worker1'
|
|
||||||
option pool2url 'stratum+tcp://ca.stratum.slushpool.com:3333'
|
|
||||||
option pool2user 'poolacct.worker2'
|
|
||||||
option pool3url 'stratum+tcp://ca.stratum.slushpool.com:3333'
|
|
||||||
option pool3user 'poolacct.worker3'
|
|
||||||
option ntp_enable 'openwrt'
|
|
||||||
|
|
||||||
116
data/__init__.py
Normal file
116
data/__init__.py
Normal file
@@ -0,0 +1,116 @@
|
|||||||
|
from dataclasses import dataclass, field, asdict
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class MinerData:
|
||||||
|
"""A Dataclass to standardize data returned from miners (specifically AnyMiner().get_data())
|
||||||
|
|
||||||
|
:param ip: The IP of the miner as a str.
|
||||||
|
:param datetime: The time and date this data was generated.
|
||||||
|
:param model: The model of the miner as a str.
|
||||||
|
:param hostname: The network hostname of the miner as a str.
|
||||||
|
:param hashrate: The hashrate of the miner in TH/s as a int.
|
||||||
|
:param left_board_temp: The temp of the left PCB as an int.
|
||||||
|
:param left_board_chip_temp: The temp of the left board chips as an int.
|
||||||
|
:param center_board_temp: The temp of the center PCB as an int.
|
||||||
|
:param center_board_chip_temp: The temp of the center board chips as an int.
|
||||||
|
:param right_board_temp: The temp of the right PCB as an int.
|
||||||
|
:param right_board_chip_temp: The temp of the right board chips as an int.
|
||||||
|
:param wattage: Wattage of the miner as an int.
|
||||||
|
:param fan_1: The speed of the first fan as an int.
|
||||||
|
:param fan_2: The speed of the second fan as an int.
|
||||||
|
:param fan_3: The speed of the third fan as an int.
|
||||||
|
:param fan_4: The speed of the fourth fan as an int.
|
||||||
|
:param left_chips: The number of chips online in the left board as an int.
|
||||||
|
:param center_chips: The number of chips online in the left board as an int.
|
||||||
|
:param right_chips: The number of chips online in the left board as an int.
|
||||||
|
:param ideal_chips: The ideal number of chips in the miner as an int.
|
||||||
|
:param pool_split: The pool split as a str.
|
||||||
|
:param pool_1_url: The first pool url on the miner as a str.
|
||||||
|
:param pool_1_user: The first pool user on the miner as a str.
|
||||||
|
:param pool_2_url: The second pool url on the miner as a str.
|
||||||
|
:param pool_2_user: The second pool user on the miner as a str.
|
||||||
|
"""
|
||||||
|
|
||||||
|
ip: str
|
||||||
|
datetime: datetime = None
|
||||||
|
mac: str = "00:00:00:00:00:00"
|
||||||
|
model: str = "Unknown"
|
||||||
|
hostname: str = "Unknown"
|
||||||
|
hashrate: float = 0
|
||||||
|
temperature_avg: int = field(init=False)
|
||||||
|
env_temp: float = 0
|
||||||
|
left_board_temp: int = 0
|
||||||
|
left_board_chip_temp: int = 0
|
||||||
|
center_board_temp: int = 0
|
||||||
|
center_board_chip_temp: int = 0
|
||||||
|
right_board_temp: int = 0
|
||||||
|
right_board_chip_temp: int = 0
|
||||||
|
wattage: int = 0
|
||||||
|
fan_1: int = -1
|
||||||
|
fan_2: int = -1
|
||||||
|
fan_3: int = -1
|
||||||
|
fan_4: int = -1
|
||||||
|
left_chips: int = 0
|
||||||
|
center_chips: int = 0
|
||||||
|
right_chips: int = 0
|
||||||
|
total_chips: int = field(init=False)
|
||||||
|
ideal_chips: int = 1
|
||||||
|
percent_ideal: float = field(init=False)
|
||||||
|
nominal: int = field(init=False)
|
||||||
|
pool_split: str = "0"
|
||||||
|
pool_1_url: str = "Unknown"
|
||||||
|
pool_1_user: str = "Unknown"
|
||||||
|
pool_2_url: str = ""
|
||||||
|
pool_2_user: str = ""
|
||||||
|
|
||||||
|
def __post_init__(self):
|
||||||
|
self.datetime = datetime.now()
|
||||||
|
|
||||||
|
@property
|
||||||
|
def total_chips(self): # noqa - Skip PyCharm inspection
|
||||||
|
return self.right_chips + self.center_chips + self.left_chips
|
||||||
|
|
||||||
|
@total_chips.setter
|
||||||
|
def total_chips(self, val):
|
||||||
|
pass
|
||||||
|
|
||||||
|
@property
|
||||||
|
def nominal(self): # noqa - Skip PyCharm inspection
|
||||||
|
return self.ideal_chips == self.total_chips
|
||||||
|
|
||||||
|
@nominal.setter
|
||||||
|
def nominal(self, val):
|
||||||
|
pass
|
||||||
|
|
||||||
|
@property
|
||||||
|
def percent_ideal(self): # noqa - Skip PyCharm inspection
|
||||||
|
return round((self.total_chips / self.ideal_chips) * 100)
|
||||||
|
|
||||||
|
@percent_ideal.setter
|
||||||
|
def percent_ideal(self, val):
|
||||||
|
pass
|
||||||
|
|
||||||
|
@property
|
||||||
|
def temperature_avg(self): # noqa - Skip PyCharm inspection
|
||||||
|
total_temp = 0
|
||||||
|
temp_count = 0
|
||||||
|
for temp in [
|
||||||
|
self.left_board_chip_temp,
|
||||||
|
self.center_board_chip_temp,
|
||||||
|
self.right_board_chip_temp,
|
||||||
|
]:
|
||||||
|
if temp and not temp == 0:
|
||||||
|
total_temp += temp
|
||||||
|
temp_count += 1
|
||||||
|
if not temp_count > 0:
|
||||||
|
return 0
|
||||||
|
return round(total_temp / temp_count)
|
||||||
|
|
||||||
|
@temperature_avg.setter
|
||||||
|
def temperature_avg(self, val):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def asdict(self):
|
||||||
|
return asdict(self)
|
||||||
BIN
dev-requirements.txt
Normal file
BIN
dev-requirements.txt
Normal file
Binary file not shown.
@@ -1,18 +1,31 @@
|
|||||||
import logging
|
import logging
|
||||||
from settings import DEBUG
|
from settings import DEBUG, LOGFILE
|
||||||
|
|
||||||
|
|
||||||
logging.basicConfig(
|
def init_logger():
|
||||||
# filename="logfile.txt",
|
if LOGFILE:
|
||||||
# filemode="a",
|
logging.basicConfig(
|
||||||
format="[%(levelname)s][%(asctime)s](%(name)s) - %(message)s",
|
filename="logfile.txt",
|
||||||
datefmt="%x %X",
|
filemode="a",
|
||||||
)
|
format="%(pathname)s:%(lineno)d in %(funcName)s\n[%(levelname)s][%(asctime)s](%(name)s) - %(message)s",
|
||||||
logger = logging.getLogger()
|
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",
|
||||||
|
)
|
||||||
|
|
||||||
if DEBUG:
|
_logger = logging.getLogger()
|
||||||
logger.setLevel(logging.DEBUG)
|
|
||||||
logging.getLogger("asyncssh").setLevel(logging.DEBUG)
|
if DEBUG:
|
||||||
else:
|
_logger.setLevel(logging.DEBUG)
|
||||||
logger.setLevel(logging.INFO)
|
logging.getLogger("asyncssh").setLevel(logging.DEBUG)
|
||||||
logging.getLogger("asyncssh").setLevel(logging.WARNING)
|
else:
|
||||||
|
_logger.setLevel(logging.WARNING)
|
||||||
|
logging.getLogger("asyncssh").setLevel(logging.WARNING)
|
||||||
|
|
||||||
|
return _logger
|
||||||
|
|
||||||
|
|
||||||
|
logger = init_logger()
|
||||||
|
|||||||
@@ -1,44 +0,0 @@
|
|||||||
"""
|
|
||||||
Make a build of the board tool.
|
|
||||||
|
|
||||||
Usage: make_board_tool_exe.py build
|
|
||||||
|
|
||||||
The build will show up in the build directory.
|
|
||||||
"""
|
|
||||||
import datetime
|
|
||||||
import sys
|
|
||||||
import os
|
|
||||||
from cx_Freeze import setup, Executable
|
|
||||||
|
|
||||||
base = None
|
|
||||||
if sys.platform == "win32":
|
|
||||||
base = "Win32GUI"
|
|
||||||
|
|
||||||
version = datetime.datetime.now()
|
|
||||||
version = version.strftime("%y.%m.%d")
|
|
||||||
print(version)
|
|
||||||
|
|
||||||
|
|
||||||
setup(
|
|
||||||
name="UpstreamBoardUtil.exe",
|
|
||||||
version=version,
|
|
||||||
description="Upstream Data Board Utility Build",
|
|
||||||
options={
|
|
||||||
"build_exe": {
|
|
||||||
"build_exe": f"{os.getcwd()}\\build\\board_util\\UpstreamBoardUtil-{version}-{sys.platform}\\",
|
|
||||||
"include_files": [
|
|
||||||
os.path.join(os.getcwd(), "settings/settings.toml"),
|
|
||||||
],
|
|
||||||
"include_msvcr": True,
|
|
||||||
"add_to_path": True,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
executables=[
|
|
||||||
Executable(
|
|
||||||
"board_util.py",
|
|
||||||
base=base,
|
|
||||||
icon="icon.ico",
|
|
||||||
target_name="UpstreamBoardUtil.exe",
|
|
||||||
)
|
|
||||||
],
|
|
||||||
)
|
|
||||||
@@ -9,6 +9,7 @@ import datetime
|
|||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
from cx_Freeze import setup, Executable
|
from cx_Freeze import setup, Executable
|
||||||
|
from setuptools import find_packages
|
||||||
|
|
||||||
base = None
|
base = None
|
||||||
if sys.platform == "win32":
|
if sys.platform == "win32":
|
||||||
@@ -16,7 +17,6 @@ if sys.platform == "win32":
|
|||||||
|
|
||||||
version = datetime.datetime.now()
|
version = datetime.datetime.now()
|
||||||
version = version.strftime("%y.%m.%d")
|
version = version.strftime("%y.%m.%d")
|
||||||
print(version)
|
|
||||||
|
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
@@ -30,6 +30,7 @@ setup(
|
|||||||
os.path.join(os.getcwd(), "settings/settings.toml"),
|
os.path.join(os.getcwd(), "settings/settings.toml"),
|
||||||
os.path.join(os.getcwd(), "static/CFG-Util-README.md"),
|
os.path.join(os.getcwd(), "static/CFG-Util-README.md"),
|
||||||
],
|
],
|
||||||
|
"excludes": ["tests", "tools.web_testbench", "tools.web_monitor"],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
executables=[
|
executables=[
|
||||||
|
|||||||
@@ -1,27 +1,36 @@
|
|||||||
from API.bmminer import BMMinerAPI
|
|
||||||
from API.bosminer import BOSMinerAPI
|
|
||||||
from API.cgminer import CGMinerAPI
|
|
||||||
from API.btminer import BTMinerAPI
|
|
||||||
from API.unknown import UnknownAPI
|
|
||||||
import ipaddress
|
|
||||||
import asyncssh
|
import asyncssh
|
||||||
import logging
|
import logging
|
||||||
|
import ipaddress
|
||||||
|
|
||||||
|
from data import MinerData
|
||||||
|
|
||||||
|
|
||||||
class BaseMiner:
|
class BaseMiner:
|
||||||
def __init__(
|
def __init__(self, *args) -> None:
|
||||||
self,
|
self.ip = None
|
||||||
ip: str,
|
self.uname = "root"
|
||||||
api: BMMinerAPI or BOSMinerAPI or CGMinerAPI or BTMinerAPI or UnknownAPI,
|
self.pwd = "admin"
|
||||||
) -> None:
|
self.api = None
|
||||||
self.ip = ipaddress.ip_address(ip)
|
|
||||||
self.uname = None
|
|
||||||
self.pwd = None
|
|
||||||
self.api = api
|
|
||||||
self.api_type = None
|
self.api_type = None
|
||||||
self.model = None
|
self.model = None
|
||||||
self.light = None
|
self.light = None
|
||||||
|
self.hostname = None
|
||||||
self.nominal_chips = 1
|
self.nominal_chips = 1
|
||||||
|
self.version = None
|
||||||
|
self.fan_count = 2
|
||||||
|
self.config = None
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return f"{'' if not self.api_type else self.api_type} {'' if not self.model else 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)
|
||||||
|
|
||||||
async def _get_ssh_connection(self) -> asyncssh.connect:
|
async def _get_ssh_connection(self) -> asyncssh.connect:
|
||||||
"""Create a new asyncssh connection"""
|
"""Create a new asyncssh connection"""
|
||||||
@@ -39,20 +48,26 @@ class BaseMiner:
|
|||||||
conn = await asyncssh.connect(
|
conn = await asyncssh.connect(
|
||||||
str(self.ip),
|
str(self.ip),
|
||||||
known_hosts=None,
|
known_hosts=None,
|
||||||
username="admin",
|
username="root",
|
||||||
password="admin",
|
password="admin",
|
||||||
server_host_key_algs=["ssh-rsa"],
|
server_host_key_algs=["ssh-rsa"],
|
||||||
)
|
)
|
||||||
return conn
|
return conn
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.warning(f"{self} raised an exception: {e}")
|
# logging.warning(f"{self} raised an exception: {e}")
|
||||||
raise e
|
raise e
|
||||||
except OSError:
|
except OSError as e:
|
||||||
logging.warning(f"Connection refused: {self}")
|
logging.warning(f"Connection refused: {self}")
|
||||||
return None
|
|
||||||
except Exception as e:
|
|
||||||
logging.warning(f"{self} raised an exception: {e}")
|
|
||||||
raise e
|
raise e
|
||||||
|
except Exception as e:
|
||||||
|
# logging.warning(f"{self} raised an exception: {e}")
|
||||||
|
raise e
|
||||||
|
|
||||||
|
async def fault_light_on(self) -> bool:
|
||||||
|
return False
|
||||||
|
|
||||||
|
async def fault_light_off(self) -> bool:
|
||||||
|
return False
|
||||||
|
|
||||||
async def send_file(self, src, dest):
|
async def send_file(self, src, dest):
|
||||||
async with (await self._get_ssh_connection()) as conn:
|
async with (await self._get_ssh_connection()) as conn:
|
||||||
@@ -74,10 +89,16 @@ class BaseMiner:
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
async def reboot(self):
|
async def reboot(self):
|
||||||
return None
|
return False
|
||||||
|
|
||||||
async def restart_backend(self):
|
async def restart_backend(self):
|
||||||
|
return False
|
||||||
|
|
||||||
|
async def send_config(self, *args, **kwargs):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
async def send_config(self, yaml_config):
|
async def get_mac(self):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
async def get_data(self) -> MinerData:
|
||||||
|
return MinerData(ip=str(self.ip))
|
||||||
|
|||||||
5
miners/_backends/__init__.py
Normal file
5
miners/_backends/__init__.py
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
from .bmminer import BMMiner
|
||||||
|
from .bosminer import BOSMiner
|
||||||
|
from .btminer import BTMiner
|
||||||
|
from .cgminer import CGMiner
|
||||||
|
from .hiveon import Hiveon
|
||||||
264
miners/_backends/bmminer.py
Normal file
264
miners/_backends/bmminer.py
Normal file
@@ -0,0 +1,264 @@
|
|||||||
|
import ipaddress
|
||||||
|
import logging
|
||||||
|
|
||||||
|
|
||||||
|
from API.bmminer import BMMinerAPI
|
||||||
|
from miners import BaseMiner
|
||||||
|
|
||||||
|
from data import MinerData
|
||||||
|
|
||||||
|
from settings import MINER_FACTORY_GET_VERSION_RETRIES as DATA_RETRIES
|
||||||
|
|
||||||
|
|
||||||
|
class BMMiner(BaseMiner):
|
||||||
|
def __init__(self, ip: str) -> None:
|
||||||
|
super().__init__(ip)
|
||||||
|
self.ip = ipaddress.ip_address(ip)
|
||||||
|
self.api = BMMinerAPI(ip)
|
||||||
|
self.api_type = "BMMiner"
|
||||||
|
self.uname = "root"
|
||||||
|
self.pwd = "admin"
|
||||||
|
|
||||||
|
async def get_model(self) -> str or None:
|
||||||
|
"""Get miner model.
|
||||||
|
|
||||||
|
:return: Miner model or None.
|
||||||
|
"""
|
||||||
|
# check if model is cached
|
||||||
|
if self.model:
|
||||||
|
logging.debug(f"Found model for {self.ip}: {self.model}")
|
||||||
|
return self.model
|
||||||
|
|
||||||
|
# get devdetails data
|
||||||
|
version_data = await self.api.devdetails()
|
||||||
|
|
||||||
|
# if we get data back, parse it for model
|
||||||
|
if version_data:
|
||||||
|
# handle Antminer BMMiner as a base
|
||||||
|
self.model = version_data["DEVDETAILS"][0]["Model"].replace("Antminer ", "")
|
||||||
|
logging.debug(f"Found model for {self.ip}: {self.model}")
|
||||||
|
return self.model
|
||||||
|
|
||||||
|
# if we don't get devdetails, log a failed attempt
|
||||||
|
logging.warning(f"Failed to get model for miner: {self}")
|
||||||
|
return None
|
||||||
|
|
||||||
|
async def get_hostname(self) -> str:
|
||||||
|
"""Get miner hostname.
|
||||||
|
|
||||||
|
:return: The hostname of the miner as a string or "?"
|
||||||
|
"""
|
||||||
|
if self.hostname:
|
||||||
|
return self.hostname
|
||||||
|
try:
|
||||||
|
# open an ssh connection
|
||||||
|
async with (await self._get_ssh_connection()) as conn:
|
||||||
|
# if we get the connection, check hostname
|
||||||
|
if conn is not None:
|
||||||
|
# get output of the hostname file
|
||||||
|
data = await conn.run("cat /proc/sys/kernel/hostname")
|
||||||
|
host = data.stdout.strip()
|
||||||
|
|
||||||
|
# return hostname data
|
||||||
|
logging.debug(f"Found hostname for {self.ip}: {host}")
|
||||||
|
self.hostname = host
|
||||||
|
return self.hostname
|
||||||
|
else:
|
||||||
|
# return ? if we fail to get hostname with no ssh connection
|
||||||
|
logging.warning(f"Failed to get hostname for miner: {self}")
|
||||||
|
return "?"
|
||||||
|
except Exception:
|
||||||
|
# return ? if we fail to get hostname with an exception
|
||||||
|
logging.warning(f"Failed to get hostname for miner: {self}")
|
||||||
|
return "?"
|
||||||
|
|
||||||
|
async def send_ssh_command(self, cmd: str) -> str or None:
|
||||||
|
"""Send a command to the miner over ssh.
|
||||||
|
|
||||||
|
:param cmd: The command to run.
|
||||||
|
|
||||||
|
:return: Result of the command or None.
|
||||||
|
"""
|
||||||
|
result = None
|
||||||
|
|
||||||
|
# open an ssh connection
|
||||||
|
async with (await self._get_ssh_connection()) as conn:
|
||||||
|
# 3 retries
|
||||||
|
for i in range(3):
|
||||||
|
try:
|
||||||
|
# run the command and get the result
|
||||||
|
result = await conn.run(cmd)
|
||||||
|
result = result.stdout
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
# if the command fails, log it
|
||||||
|
logging.warning(f"{self} command {cmd} error: {e}")
|
||||||
|
|
||||||
|
# on the 3rd retry, return None
|
||||||
|
if i == 3:
|
||||||
|
return
|
||||||
|
continue
|
||||||
|
# return the result, either command output or None
|
||||||
|
return result
|
||||||
|
|
||||||
|
async def get_config(self) -> list or None:
|
||||||
|
"""Get the pool configuration of the miner.
|
||||||
|
|
||||||
|
:return: Pool config data or None.
|
||||||
|
"""
|
||||||
|
# get pool data
|
||||||
|
pools = await self.api.pools()
|
||||||
|
pool_data = []
|
||||||
|
|
||||||
|
# ensure we got pool data
|
||||||
|
if not pools:
|
||||||
|
return
|
||||||
|
|
||||||
|
# parse all the pools
|
||||||
|
for pool in pools["POOLS"]:
|
||||||
|
pool_data.append({"url": pool["URL"], "user": pool["User"], "pwd": "123"})
|
||||||
|
return pool_data
|
||||||
|
|
||||||
|
async def reboot(self) -> bool:
|
||||||
|
logging.debug(f"{self}: Sending reboot command.")
|
||||||
|
_ret = await self.send_ssh_command("reboot")
|
||||||
|
logging.debug(f"{self}: Reboot command completed.")
|
||||||
|
if isinstance(_ret, str):
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
async def get_data(self) -> MinerData:
|
||||||
|
data = MinerData(ip=str(self.ip), ideal_chips=self.nominal_chips * 3)
|
||||||
|
|
||||||
|
board_offset = -1
|
||||||
|
fan_offset = -1
|
||||||
|
|
||||||
|
model = await self.get_model()
|
||||||
|
hostname = await self.get_hostname()
|
||||||
|
mac = await self.get_mac()
|
||||||
|
|
||||||
|
if model:
|
||||||
|
data.model = model
|
||||||
|
|
||||||
|
if hostname:
|
||||||
|
data.hostname = hostname
|
||||||
|
|
||||||
|
if mac:
|
||||||
|
data.mac = mac
|
||||||
|
|
||||||
|
miner_data = None
|
||||||
|
for i in range(DATA_RETRIES):
|
||||||
|
miner_data = await self.api.multicommand(
|
||||||
|
"summary", "pools", "stats", ignore_x19_error=True
|
||||||
|
)
|
||||||
|
if miner_data:
|
||||||
|
break
|
||||||
|
|
||||||
|
if not miner_data:
|
||||||
|
return data
|
||||||
|
|
||||||
|
summary = miner_data.get("summary")[0]
|
||||||
|
pools = miner_data.get("pools")[0]
|
||||||
|
stats = miner_data.get("stats")[0]
|
||||||
|
|
||||||
|
if summary:
|
||||||
|
hr = summary.get("SUMMARY")
|
||||||
|
if hr:
|
||||||
|
if len(hr) > 0:
|
||||||
|
hr = hr[0].get("GHS av")
|
||||||
|
if hr:
|
||||||
|
data.hashrate = round(hr / 1000, 2)
|
||||||
|
|
||||||
|
if stats:
|
||||||
|
boards = stats.get("STATS")
|
||||||
|
if boards:
|
||||||
|
if len(boards) > 0:
|
||||||
|
for board_num in range(1, 16, 5):
|
||||||
|
for _b_num in range(5):
|
||||||
|
b = boards[1].get(f"chain_acn{board_num + _b_num}")
|
||||||
|
|
||||||
|
if b and not b == 0 and board_offset == -1:
|
||||||
|
board_offset = board_num
|
||||||
|
if board_offset == -1:
|
||||||
|
board_offset = 1
|
||||||
|
|
||||||
|
data.left_chips = boards[1].get(f"chain_acn{board_offset}")
|
||||||
|
data.center_chips = boards[1].get(f"chain_acn{board_offset+1}")
|
||||||
|
data.right_chips = boards[1].get(f"chain_acn{board_offset+2}")
|
||||||
|
|
||||||
|
if stats:
|
||||||
|
temp = stats.get("STATS")
|
||||||
|
if temp:
|
||||||
|
if len(temp) > 1:
|
||||||
|
for fan_num in range(1, 8, 4):
|
||||||
|
for _f_num in range(4):
|
||||||
|
f = temp[1].get(f"fan{fan_num + _f_num}")
|
||||||
|
if f and not f == 0 and fan_offset == -1:
|
||||||
|
fan_offset = fan_num
|
||||||
|
if fan_offset == -1:
|
||||||
|
fan_offset = 1
|
||||||
|
for fan in range(self.fan_count):
|
||||||
|
setattr(
|
||||||
|
data, f"fan_{fan + 1}", temp[1].get(f"fan{fan_offset+fan}")
|
||||||
|
)
|
||||||
|
|
||||||
|
board_map = {0: "left_board", 1: "center_board", 2: "right_board"}
|
||||||
|
env_temp_list = []
|
||||||
|
for item in range(3):
|
||||||
|
board_temp = temp[1].get(f"temp{item + board_offset}")
|
||||||
|
chip_temp = temp[1].get(f"temp2_{item + board_offset}")
|
||||||
|
setattr(data, f"{board_map[item]}_chip_temp", chip_temp)
|
||||||
|
setattr(data, f"{board_map[item]}_temp", board_temp)
|
||||||
|
if f"temp_pcb{item}" in temp[1].keys():
|
||||||
|
env_temp = temp[1][f"temp_pcb{item}"].split("-")[0]
|
||||||
|
if not env_temp == 0:
|
||||||
|
env_temp_list.append(int(env_temp))
|
||||||
|
data.env_temp = sum(env_temp_list) / len(env_temp_list)
|
||||||
|
|
||||||
|
if pools:
|
||||||
|
pool_1 = None
|
||||||
|
pool_2 = None
|
||||||
|
pool_1_user = None
|
||||||
|
pool_2_user = None
|
||||||
|
pool_1_quota = 1
|
||||||
|
pool_2_quota = 1
|
||||||
|
quota = 0
|
||||||
|
for pool in pools.get("POOLS"):
|
||||||
|
if not pool_1_user:
|
||||||
|
pool_1_user = pool.get("User")
|
||||||
|
pool_1 = pool["URL"]
|
||||||
|
pool_1_quota = pool["Quota"]
|
||||||
|
elif not pool_2_user:
|
||||||
|
pool_2_user = pool.get("User")
|
||||||
|
pool_2 = pool["URL"]
|
||||||
|
pool_2_quota = pool["Quota"]
|
||||||
|
if not pool.get("User") == pool_1_user:
|
||||||
|
if not pool_2_user == pool.get("User"):
|
||||||
|
pool_2_user = pool.get("User")
|
||||||
|
pool_2 = pool["URL"]
|
||||||
|
pool_2_quota = pool["Quota"]
|
||||||
|
if pool_2_user and not pool_2_user == pool_1_user:
|
||||||
|
quota = f"{pool_1_quota}/{pool_2_quota}"
|
||||||
|
|
||||||
|
if pool_1:
|
||||||
|
pool_1 = pool_1.replace("stratum+tcp://", "").replace(
|
||||||
|
"stratum2+tcp://", ""
|
||||||
|
)
|
||||||
|
data.pool_1_url = pool_1
|
||||||
|
|
||||||
|
if pool_1_user:
|
||||||
|
data.pool_1_user = pool_1_user
|
||||||
|
|
||||||
|
if pool_2:
|
||||||
|
pool_2 = pool_2.replace("stratum+tcp://", "").replace(
|
||||||
|
"stratum2+tcp://", ""
|
||||||
|
)
|
||||||
|
data.pool_2_url = pool_2
|
||||||
|
|
||||||
|
if pool_2_user:
|
||||||
|
data.pool_2_user = pool_2_user
|
||||||
|
|
||||||
|
if quota:
|
||||||
|
data.pool_split = str(quota)
|
||||||
|
|
||||||
|
return data
|
||||||
@@ -1,23 +1,30 @@
|
|||||||
|
import ipaddress
|
||||||
|
import logging
|
||||||
|
import json
|
||||||
|
|
||||||
|
import toml
|
||||||
|
|
||||||
|
|
||||||
from miners import BaseMiner
|
from miners import BaseMiner
|
||||||
from API.bosminer import BOSMinerAPI
|
from API.bosminer import BOSMinerAPI
|
||||||
import toml
|
from API import APIError
|
||||||
from config.bos import bos_config_convert, general_config_convert_bos
|
|
||||||
import logging
|
from data import MinerData
|
||||||
|
|
||||||
|
from config import MinerConfig
|
||||||
|
|
||||||
|
from settings import MINER_FACTORY_GET_VERSION_RETRIES as DATA_RETRIES
|
||||||
|
|
||||||
|
|
||||||
class BOSMiner(BaseMiner):
|
class BOSMiner(BaseMiner):
|
||||||
def __init__(self, ip: str) -> None:
|
def __init__(self, ip: str) -> None:
|
||||||
api = BOSMinerAPI(ip)
|
super().__init__(ip)
|
||||||
super().__init__(ip, api)
|
self.ip = ipaddress.ip_address(ip)
|
||||||
self.model = None
|
self.api = BOSMinerAPI(ip)
|
||||||
self.config = None
|
self.api_type = "BOSMiner"
|
||||||
self.version = None
|
|
||||||
self.uname = "root"
|
self.uname = "root"
|
||||||
self.pwd = "admin"
|
self.pwd = "admin"
|
||||||
self.nominal_chips = 63
|
self.config = None
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
|
||||||
return f"BOSminer: {str(self.ip)}"
|
|
||||||
|
|
||||||
async def send_ssh_command(self, cmd: str) -> str or None:
|
async def send_ssh_command(self, cmd: str) -> str or None:
|
||||||
"""Send a command to the miner over ssh.
|
"""Send a command to the miner over ssh.
|
||||||
@@ -33,6 +40,7 @@ class BOSMiner(BaseMiner):
|
|||||||
try:
|
try:
|
||||||
# run the command and get the result
|
# run the command and get the result
|
||||||
result = await conn.run(cmd)
|
result = await conn.run(cmd)
|
||||||
|
result = result.stdout
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
# if the command fails, log it
|
# if the command fails, log it
|
||||||
logging.warning(f"{self} command {cmd} error: {e}")
|
logging.warning(f"{self} command {cmd} error: {e}")
|
||||||
@@ -42,36 +50,48 @@ class BOSMiner(BaseMiner):
|
|||||||
return
|
return
|
||||||
continue
|
continue
|
||||||
# return the result, either command output or None
|
# return the result, either command output or None
|
||||||
return result
|
return str(result)
|
||||||
|
|
||||||
async def fault_light_on(self) -> None:
|
async def fault_light_on(self) -> bool:
|
||||||
"""Sends command to turn on fault light on the miner."""
|
"""Sends command to turn on fault light on the miner."""
|
||||||
logging.debug(f"{self}: Sending fault_light on command.")
|
logging.debug(f"{self}: Sending fault_light on command.")
|
||||||
self.light = True
|
self.light = True
|
||||||
await self.send_ssh_command("miner fault_light on")
|
_ret = await self.send_ssh_command("miner fault_light on")
|
||||||
logging.debug(f"{self}: fault_light on command completed.")
|
logging.debug(f"{self}: fault_light on command completed.")
|
||||||
|
if isinstance(_ret, str):
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
async def fault_light_off(self) -> None:
|
async def fault_light_off(self) -> bool:
|
||||||
"""Sends command to turn off fault light on the miner."""
|
"""Sends command to turn off fault light on the miner."""
|
||||||
logging.debug(f"{self}: Sending fault_light off command.")
|
logging.debug(f"{self}: Sending fault_light off command.")
|
||||||
self.light = False
|
self.light = False
|
||||||
await self.send_ssh_command("miner fault_light off")
|
_ret = await self.send_ssh_command("miner fault_light off")
|
||||||
logging.debug(f"{self}: fault_light off command completed.")
|
logging.debug(f"{self}: fault_light off command completed.")
|
||||||
|
if isinstance(_ret, str):
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
async def restart_backend(self) -> None:
|
async def restart_backend(self) -> bool:
|
||||||
await self.restart_bosminer()
|
return await self.restart_bosminer()
|
||||||
|
|
||||||
async def restart_bosminer(self) -> None:
|
async def restart_bosminer(self) -> bool:
|
||||||
"""Restart bosminer hashing process."""
|
"""Restart bosminer hashing process."""
|
||||||
logging.debug(f"{self}: Sending bosminer restart command.")
|
logging.debug(f"{self}: Sending bosminer restart command.")
|
||||||
await self.send_ssh_command("/etc/init.d/bosminer restart")
|
_ret = await self.send_ssh_command("/etc/init.d/bosminer restart")
|
||||||
logging.debug(f"{self}: bosminer restart command completed.")
|
logging.debug(f"{self}: bosminer restart command completed.")
|
||||||
|
if isinstance(_ret, str):
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
async def reboot(self) -> None:
|
async def reboot(self) -> bool:
|
||||||
"""Reboots power to the physical miner."""
|
"""Reboots power to the physical miner."""
|
||||||
logging.debug(f"{self}: Sending reboot command.")
|
logging.debug(f"{self}: Sending reboot command.")
|
||||||
await self.send_ssh_command("/sbin/reboot")
|
_ret = await self.send_ssh_command("/sbin/reboot")
|
||||||
logging.debug(f"{self}: Reboot command completed.")
|
logging.debug(f"{self}: Reboot command completed.")
|
||||||
|
if isinstance(_ret, str):
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
async def get_config(self) -> None:
|
async def get_config(self) -> None:
|
||||||
logging.debug(f"{self}: Getting config.")
|
logging.debug(f"{self}: Getting config.")
|
||||||
@@ -82,25 +102,29 @@ class BOSMiner(BaseMiner):
|
|||||||
async with sftp.open("/etc/bosminer.toml") as file:
|
async with sftp.open("/etc/bosminer.toml") as file:
|
||||||
toml_data = toml.loads(await file.read())
|
toml_data = toml.loads(await file.read())
|
||||||
logging.debug(f"{self}: Converting config file.")
|
logging.debug(f"{self}: Converting config file.")
|
||||||
cfg = await bos_config_convert(toml_data)
|
cfg = MinerConfig().from_raw(toml_data)
|
||||||
self.config = cfg
|
self.config = cfg
|
||||||
|
return self.config
|
||||||
|
|
||||||
async def get_hostname(self) -> str:
|
async def get_hostname(self) -> str:
|
||||||
"""Get miner hostname.
|
"""Get miner hostname.
|
||||||
|
|
||||||
:return: The hostname of the miner as a string or "?"
|
:return: The hostname of the miner as a string or "?"
|
||||||
"""
|
"""
|
||||||
|
if self.hostname:
|
||||||
|
return self.hostname
|
||||||
try:
|
try:
|
||||||
async with (await self._get_ssh_connection()) as conn:
|
async with (await self._get_ssh_connection()) as conn:
|
||||||
if conn is not None:
|
if conn is not None:
|
||||||
data = await conn.run("cat /proc/sys/kernel/hostname")
|
data = await conn.run("cat /proc/sys/kernel/hostname")
|
||||||
host = data.stdout.strip()
|
host = data.stdout.strip()
|
||||||
logging.debug(f"Found hostname for {self.ip}: {host}")
|
logging.debug(f"Found hostname for {self.ip}: {host}")
|
||||||
return host
|
self.hostname = host
|
||||||
|
return self.hostname
|
||||||
else:
|
else:
|
||||||
logging.warning(f"Failed to get hostname for miner: {self}")
|
logging.warning(f"Failed to get hostname for miner: {self}")
|
||||||
return "?"
|
return "?"
|
||||||
except Exception as e:
|
except Exception:
|
||||||
logging.warning(f"Failed to get hostname for miner: {self}")
|
logging.warning(f"Failed to get hostname for miner: {self}")
|
||||||
return "?"
|
return "?"
|
||||||
|
|
||||||
@@ -115,7 +139,17 @@ class BOSMiner(BaseMiner):
|
|||||||
return self.model + " (BOS)"
|
return self.model + " (BOS)"
|
||||||
|
|
||||||
# get devdetails data
|
# get devdetails data
|
||||||
version_data = await self.api.devdetails()
|
try:
|
||||||
|
version_data = await self.api.devdetails()
|
||||||
|
except APIError as e:
|
||||||
|
version_data = None
|
||||||
|
if e.message == "Not ready":
|
||||||
|
cfg = json.loads(await self.send_ssh_command("bosminer config --data"))
|
||||||
|
model = cfg.get("data").get("format").get("model")
|
||||||
|
if model:
|
||||||
|
model = model.replace("Antminer ", "")
|
||||||
|
self.model = model
|
||||||
|
return self.model + " (BOS)"
|
||||||
|
|
||||||
# if we get data back, parse it for model
|
# if we get data back, parse it for model
|
||||||
if version_data:
|
if version_data:
|
||||||
@@ -146,7 +180,7 @@ class BOSMiner(BaseMiner):
|
|||||||
|
|
||||||
# if we get the version data, parse it
|
# if we get the version data, parse it
|
||||||
if version_data:
|
if version_data:
|
||||||
self.version = version_data.stdout.split("-")[5]
|
self.version = version_data.split("-")[5]
|
||||||
logging.debug(f"Found version for {self.ip}: {self.version}")
|
logging.debug(f"Found version for {self.ip}: {self.version}")
|
||||||
return self.version
|
return self.version
|
||||||
|
|
||||||
@@ -159,11 +193,17 @@ class BOSMiner(BaseMiner):
|
|||||||
logging.debug(f"{self}: Sending config.")
|
logging.debug(f"{self}: Sending config.")
|
||||||
if ip_user:
|
if ip_user:
|
||||||
suffix = str(self.ip).split(".")[-1]
|
suffix = str(self.ip).split(".")[-1]
|
||||||
toml_conf = toml.dumps(
|
toml_conf = (
|
||||||
await general_config_convert_bos(yaml_config, user_suffix=suffix)
|
MinerConfig()
|
||||||
|
.from_yaml(yaml_config)
|
||||||
|
.as_bos(model=self.model.replace(" (BOS)", ""), user_suffix=suffix)
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
toml_conf = toml.dumps(await general_config_convert_bos(yaml_config))
|
toml_conf = (
|
||||||
|
MinerConfig()
|
||||||
|
.from_yaml(yaml_config)
|
||||||
|
.as_bos(model=self.model.replace(" (BOS)", ""))
|
||||||
|
)
|
||||||
async with (await self._get_ssh_connection()) as conn:
|
async with (await self._get_ssh_connection()) as conn:
|
||||||
logging.debug(f"{self}: Opening SFTP connection.")
|
logging.debug(f"{self}: Opening SFTP connection.")
|
||||||
async with conn.start_sftp_client() as sftp:
|
async with conn.start_sftp_client() as sftp:
|
||||||
@@ -222,3 +262,142 @@ class BOSMiner(BaseMiner):
|
|||||||
bad += 1
|
bad += 1
|
||||||
if not bad > 0:
|
if not bad > 0:
|
||||||
return str(self.ip)
|
return str(self.ip)
|
||||||
|
|
||||||
|
async def get_data(self) -> MinerData:
|
||||||
|
data = MinerData(ip=str(self.ip), ideal_chips=self.nominal_chips * 3)
|
||||||
|
|
||||||
|
board_offset = -1
|
||||||
|
fan_offset = -1
|
||||||
|
|
||||||
|
model = await self.get_model()
|
||||||
|
hostname = await self.get_hostname()
|
||||||
|
mac = await self.get_mac()
|
||||||
|
|
||||||
|
if model:
|
||||||
|
data.model = model
|
||||||
|
|
||||||
|
if hostname:
|
||||||
|
data.hostname = hostname
|
||||||
|
|
||||||
|
if mac:
|
||||||
|
data.mac = mac
|
||||||
|
|
||||||
|
miner_data = None
|
||||||
|
for i in range(DATA_RETRIES):
|
||||||
|
try:
|
||||||
|
miner_data = await self.api.multicommand(
|
||||||
|
"summary", "temps", "tunerstatus", "pools", "devdetails", "fans"
|
||||||
|
)
|
||||||
|
except APIError as e:
|
||||||
|
if str(e.message) == "Not ready":
|
||||||
|
miner_data = await self.api.multicommand(
|
||||||
|
"summary", "tunerstatus", "pools", "fans"
|
||||||
|
)
|
||||||
|
if miner_data:
|
||||||
|
break
|
||||||
|
if not miner_data:
|
||||||
|
return data
|
||||||
|
summary = miner_data.get("summary")
|
||||||
|
temps = miner_data.get("temps")
|
||||||
|
tunerstatus = miner_data.get("tunerstatus")
|
||||||
|
pools = miner_data.get("pools")
|
||||||
|
devdetails = miner_data.get("devdetails")
|
||||||
|
fans = miner_data.get("fans")
|
||||||
|
|
||||||
|
if summary:
|
||||||
|
hr = summary[0].get("SUMMARY")
|
||||||
|
if hr:
|
||||||
|
if len(hr) > 0:
|
||||||
|
hr = hr[0].get("MHS 1m")
|
||||||
|
if hr:
|
||||||
|
data.hashrate = round(hr / 1000000, 2)
|
||||||
|
|
||||||
|
if temps:
|
||||||
|
temp = temps[0].get("TEMPS")
|
||||||
|
if temp:
|
||||||
|
if len(temp) > 0:
|
||||||
|
board_map = {0: "left_board", 1: "center_board", 2: "right_board"}
|
||||||
|
offset = 6 if temp[0]["ID"] in [6, 7, 8] else temp[0]["ID"]
|
||||||
|
for board in temp:
|
||||||
|
_id = board["ID"] - offset
|
||||||
|
chip_temp = round(board["Chip"])
|
||||||
|
board_temp = round(board["Board"])
|
||||||
|
setattr(data, f"{board_map[_id]}_chip_temp", chip_temp)
|
||||||
|
setattr(data, f"{board_map[_id]}_temp", board_temp)
|
||||||
|
|
||||||
|
if fans:
|
||||||
|
fan_data = fans[0].get("FANS")
|
||||||
|
if fan_data:
|
||||||
|
for fan in range(self.fan_count):
|
||||||
|
setattr(data, f"fan_{fan+1}", fan_data[fan]["RPM"])
|
||||||
|
|
||||||
|
if pools:
|
||||||
|
pool_1 = None
|
||||||
|
pool_2 = None
|
||||||
|
pool_1_user = None
|
||||||
|
pool_2_user = None
|
||||||
|
pool_1_quota = 1
|
||||||
|
pool_2_quota = 1
|
||||||
|
quota = 0
|
||||||
|
for pool in pools[0].get("POOLS"):
|
||||||
|
if not pool_1_user:
|
||||||
|
pool_1_user = pool.get("User")
|
||||||
|
pool_1 = pool["URL"]
|
||||||
|
pool_1_quota = pool["Quota"]
|
||||||
|
elif not pool_2_user:
|
||||||
|
pool_2_user = pool.get("User")
|
||||||
|
pool_2 = pool["URL"]
|
||||||
|
pool_2_quota = pool["Quota"]
|
||||||
|
if not pool.get("User") == pool_1_user:
|
||||||
|
if not pool_2_user == pool.get("User"):
|
||||||
|
pool_2_user = pool.get("User")
|
||||||
|
pool_2 = pool["URL"]
|
||||||
|
pool_2_quota = pool["Quota"]
|
||||||
|
if pool_2_user and not pool_2_user == pool_1_user:
|
||||||
|
quota = f"{pool_1_quota}/{pool_2_quota}"
|
||||||
|
|
||||||
|
if pool_1:
|
||||||
|
pool_1 = pool_1.replace("stratum+tcp://", "").replace(
|
||||||
|
"stratum2+tcp://", ""
|
||||||
|
)
|
||||||
|
data.pool_1_url = pool_1
|
||||||
|
|
||||||
|
if pool_1_user:
|
||||||
|
data.pool_1_user = pool_1_user
|
||||||
|
|
||||||
|
if pool_2:
|
||||||
|
pool_2 = pool_2.replace("stratum+tcp://", "").replace(
|
||||||
|
"stratum2+tcp://", ""
|
||||||
|
)
|
||||||
|
data.pool_2_url = pool_2
|
||||||
|
|
||||||
|
if pool_2_user:
|
||||||
|
data.pool_2_user = pool_2_user
|
||||||
|
|
||||||
|
if quota:
|
||||||
|
data.pool_split = str(quota)
|
||||||
|
|
||||||
|
if tunerstatus:
|
||||||
|
tuner = tunerstatus[0].get("TUNERSTATUS")
|
||||||
|
if tuner:
|
||||||
|
if len(tuner) > 0:
|
||||||
|
wattage = tuner[0].get("PowerLimit")
|
||||||
|
if wattage:
|
||||||
|
data.wattage = wattage
|
||||||
|
|
||||||
|
if devdetails:
|
||||||
|
boards = devdetails[0].get("DEVDETAILS")
|
||||||
|
if boards:
|
||||||
|
if len(boards) > 0:
|
||||||
|
board_map = {0: "left_chips", 1: "center_chips", 2: "right_chips"}
|
||||||
|
offset = 6 if boards[0]["ID"] in [6, 7, 8] else boards[0]["ID"]
|
||||||
|
for board in boards:
|
||||||
|
_id = board["ID"] - offset
|
||||||
|
chips = board["Chips"]
|
||||||
|
setattr(data, board_map[_id], chips)
|
||||||
|
|
||||||
|
return data
|
||||||
|
|
||||||
|
async def get_mac(self):
|
||||||
|
result = await self.send_ssh_command("cat /sys/class/net/eth0/address")
|
||||||
|
return result.upper().strip()
|
||||||
50
miners/_backends/bosminer_old.py
Normal file
50
miners/_backends/bosminer_old.py
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
import logging
|
||||||
|
|
||||||
|
import ipaddress
|
||||||
|
|
||||||
|
from API.bosminer import BOSMinerAPI
|
||||||
|
from miners import BaseMiner
|
||||||
|
|
||||||
|
|
||||||
|
class BOSMinerOld(BaseMiner):
|
||||||
|
def __init__(self, ip: str) -> None:
|
||||||
|
super().__init__(ip)
|
||||||
|
self.ip = ipaddress.ip_address(ip)
|
||||||
|
self.api = BOSMinerAPI(ip)
|
||||||
|
self.api_type = "BOSMiner"
|
||||||
|
self.uname = "root"
|
||||||
|
self.pwd = "admin"
|
||||||
|
|
||||||
|
async def send_ssh_command(self, cmd: str) -> str or None:
|
||||||
|
"""Send a command to the miner over ssh.
|
||||||
|
|
||||||
|
:return: Result of the command or None.
|
||||||
|
"""
|
||||||
|
result = None
|
||||||
|
|
||||||
|
# open an ssh connection
|
||||||
|
async with (await self._get_ssh_connection()) as conn:
|
||||||
|
# 3 retries
|
||||||
|
for i in range(3):
|
||||||
|
try:
|
||||||
|
# run the command and get the result
|
||||||
|
result = await conn.run(cmd)
|
||||||
|
if result.stdout:
|
||||||
|
result = result.stdout
|
||||||
|
except Exception as e:
|
||||||
|
if e == "SSH connection closed":
|
||||||
|
return "Update completed."
|
||||||
|
# if the command fails, log it
|
||||||
|
logging.warning(f"{self} command {cmd} error: {e}")
|
||||||
|
|
||||||
|
# on the 3rd retry, return None
|
||||||
|
if i == 3:
|
||||||
|
return
|
||||||
|
continue
|
||||||
|
# return the result, either command output or None
|
||||||
|
return str(result)
|
||||||
|
|
||||||
|
|
||||||
|
async def update_to_plus(self):
|
||||||
|
result = await self.send_ssh_command("opkg update && opkg install bos_plus")
|
||||||
|
return result
|
||||||
246
miners/_backends/btminer.py
Normal file
246
miners/_backends/btminer.py
Normal file
@@ -0,0 +1,246 @@
|
|||||||
|
import ipaddress
|
||||||
|
import logging
|
||||||
|
|
||||||
|
|
||||||
|
from API.btminer import BTMinerAPI
|
||||||
|
from miners import BaseMiner
|
||||||
|
from API import APIError
|
||||||
|
|
||||||
|
from data import MinerData
|
||||||
|
|
||||||
|
from settings import MINER_FACTORY_GET_VERSION_RETRIES as DATA_RETRIES
|
||||||
|
|
||||||
|
|
||||||
|
class BTMiner(BaseMiner):
|
||||||
|
def __init__(self, ip: str) -> None:
|
||||||
|
super().__init__(ip)
|
||||||
|
self.ip = ipaddress.ip_address(ip)
|
||||||
|
self.api = BTMinerAPI(ip)
|
||||||
|
self.api_type = "BTMiner"
|
||||||
|
|
||||||
|
async def get_model(self):
|
||||||
|
if self.model:
|
||||||
|
logging.debug(f"Found model for {self.ip}: {self.model}")
|
||||||
|
return self.model
|
||||||
|
version_data = await self.api.devdetails()
|
||||||
|
if version_data:
|
||||||
|
self.model = version_data["DEVDETAILS"][0]["Model"].split("V")[0]
|
||||||
|
logging.debug(f"Found model for {self.ip}: {self.model}")
|
||||||
|
return self.model
|
||||||
|
logging.warning(f"Failed to get model for miner: {self}")
|
||||||
|
return None
|
||||||
|
|
||||||
|
async def get_hostname(self) -> str or None:
|
||||||
|
if self.hostname:
|
||||||
|
return self.hostname
|
||||||
|
try:
|
||||||
|
host_data = await self.api.get_miner_info()
|
||||||
|
if host_data:
|
||||||
|
host = host_data["Msg"]["hostname"]
|
||||||
|
logging.debug(f"Found hostname for {self.ip}: {host}")
|
||||||
|
self.hostname = host
|
||||||
|
return self.hostname
|
||||||
|
except APIError:
|
||||||
|
logging.info(f"Failed to get hostname for miner: {self}")
|
||||||
|
return None
|
||||||
|
except Exception:
|
||||||
|
logging.warning(f"Failed to get hostname for miner: {self}")
|
||||||
|
return None
|
||||||
|
|
||||||
|
async def get_board_info(self) -> dict:
|
||||||
|
"""Gets data on each board and chain in the miner."""
|
||||||
|
logging.debug(f"{self}: Getting board info.")
|
||||||
|
devs = await self.api.devs()
|
||||||
|
if not devs.get("DEVS"):
|
||||||
|
print("devs error", devs)
|
||||||
|
return {0: [], 1: [], 2: []}
|
||||||
|
devs = devs["DEVS"]
|
||||||
|
boards = {}
|
||||||
|
offset = devs[0]["ID"]
|
||||||
|
for board in devs:
|
||||||
|
boards[board["ID"] - offset] = []
|
||||||
|
if "Effective Chips" in board.keys():
|
||||||
|
if not board["Effective Chips"] in self.nominal_chips:
|
||||||
|
nominal = False
|
||||||
|
else:
|
||||||
|
nominal = True
|
||||||
|
boards[board["ID"] - offset].append(
|
||||||
|
{
|
||||||
|
"chain": board["ID"] - offset,
|
||||||
|
"chip_count": board["Effective Chips"],
|
||||||
|
"chip_status": "o" * board["Effective Chips"],
|
||||||
|
"nominal": nominal,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
logging.warning(f"Incorrect board data from {self}: {board}")
|
||||||
|
print(board)
|
||||||
|
logging.debug(f"Found board data for {self}: {boards}")
|
||||||
|
return boards
|
||||||
|
|
||||||
|
async def get_mac(self):
|
||||||
|
mac = ""
|
||||||
|
data = await self.api.summary()
|
||||||
|
if data:
|
||||||
|
if data.get("SUMMARY"):
|
||||||
|
if len(data["SUMMARY"]) > 0:
|
||||||
|
_mac = data["SUMMARY"][0].get("MAC")
|
||||||
|
if _mac:
|
||||||
|
mac = _mac
|
||||||
|
if mac == "":
|
||||||
|
try:
|
||||||
|
data = await self.api.get_miner_info()
|
||||||
|
if data:
|
||||||
|
if "Msg" in data.keys():
|
||||||
|
if "mac" in data["Msg"].keys():
|
||||||
|
mac = data["Msg"]["mac"]
|
||||||
|
except APIError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
return str(mac).upper()
|
||||||
|
|
||||||
|
async def get_data(self):
|
||||||
|
data = MinerData(ip=str(self.ip), ideal_chips=self.nominal_chips * 3)
|
||||||
|
|
||||||
|
mac = None
|
||||||
|
|
||||||
|
try:
|
||||||
|
model = await self.get_model()
|
||||||
|
except APIError:
|
||||||
|
logging.info(f"Failed to get model: {self}")
|
||||||
|
model = None
|
||||||
|
data.model = "Whatsminer"
|
||||||
|
|
||||||
|
try:
|
||||||
|
hostname = await self.get_hostname()
|
||||||
|
except APIError:
|
||||||
|
logging.info(f"Failed to get hostname: {self}")
|
||||||
|
hostname = None
|
||||||
|
data.hostname = "Whatsminer"
|
||||||
|
|
||||||
|
if model:
|
||||||
|
data.model = model
|
||||||
|
|
||||||
|
if hostname:
|
||||||
|
data.hostname = hostname
|
||||||
|
|
||||||
|
miner_data = None
|
||||||
|
for i in range(DATA_RETRIES):
|
||||||
|
try:
|
||||||
|
miner_data = await self.api.multicommand("summary", "devs", "pools")
|
||||||
|
if miner_data:
|
||||||
|
break
|
||||||
|
except APIError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
if not miner_data:
|
||||||
|
return data
|
||||||
|
|
||||||
|
summary = miner_data.get("summary")[0]
|
||||||
|
devs = miner_data.get("devs")[0]
|
||||||
|
pools = miner_data.get("pools")[0]
|
||||||
|
|
||||||
|
if summary:
|
||||||
|
summary_data = summary.get("SUMMARY")
|
||||||
|
if summary_data:
|
||||||
|
if len(summary_data) > 0:
|
||||||
|
if summary_data[0].get("MAC"):
|
||||||
|
mac = summary_data[0]["MAC"]
|
||||||
|
|
||||||
|
if summary_data[0].get("Env Temp"):
|
||||||
|
data.env_temp = summary_data[0]["Env Temp"]
|
||||||
|
|
||||||
|
data.fan_1 = summary_data[0]["Fan Speed In"]
|
||||||
|
data.fan_2 = summary_data[0]["Fan Speed Out"]
|
||||||
|
|
||||||
|
hr = summary_data[0].get("MHS 1m")
|
||||||
|
if hr:
|
||||||
|
data.hashrate = round(hr / 1000000, 2)
|
||||||
|
|
||||||
|
wattage = summary_data[0].get("Power")
|
||||||
|
if wattage:
|
||||||
|
data.wattage = round(wattage)
|
||||||
|
|
||||||
|
if devs:
|
||||||
|
temp_data = devs.get("DEVS")
|
||||||
|
if temp_data:
|
||||||
|
board_map = {0: "left_board", 1: "center_board", 2: "right_board"}
|
||||||
|
for board in temp_data:
|
||||||
|
_id = board["ASC"]
|
||||||
|
chip_temp = round(board["Chip Temp Avg"])
|
||||||
|
board_temp = round(board["Temperature"])
|
||||||
|
setattr(data, f"{board_map[_id]}_chip_temp", chip_temp)
|
||||||
|
setattr(data, f"{board_map[_id]}_temp", board_temp)
|
||||||
|
|
||||||
|
if devs:
|
||||||
|
boards = devs.get("DEVS")
|
||||||
|
if boards:
|
||||||
|
if len(boards) > 0:
|
||||||
|
board_map = {0: "left_chips", 1: "center_chips", 2: "right_chips"}
|
||||||
|
if "ID" in boards[0].keys():
|
||||||
|
id_key = "ID"
|
||||||
|
else:
|
||||||
|
id_key = "ASC"
|
||||||
|
offset = boards[0][id_key]
|
||||||
|
for board in boards:
|
||||||
|
_id = board[id_key] - offset
|
||||||
|
chips = board["Effective Chips"]
|
||||||
|
setattr(data, board_map[_id], chips)
|
||||||
|
|
||||||
|
if pools:
|
||||||
|
pool_1 = None
|
||||||
|
pool_2 = None
|
||||||
|
pool_1_user = None
|
||||||
|
pool_2_user = None
|
||||||
|
pool_1_quota = 1
|
||||||
|
pool_2_quota = 1
|
||||||
|
quota = 0
|
||||||
|
for pool in pools.get("POOLS"):
|
||||||
|
if not pool_1_user:
|
||||||
|
pool_1_user = pool.get("User")
|
||||||
|
pool_1 = pool["URL"]
|
||||||
|
pool_1_quota = pool["Quota"]
|
||||||
|
elif not pool_2_user:
|
||||||
|
pool_2_user = pool.get("User")
|
||||||
|
pool_2 = pool["URL"]
|
||||||
|
pool_2_quota = pool["Quota"]
|
||||||
|
if not pool.get("User") == pool_1_user:
|
||||||
|
if not pool_2_user == pool.get("User"):
|
||||||
|
pool_2_user = pool.get("User")
|
||||||
|
pool_2 = pool["URL"]
|
||||||
|
pool_2_quota = pool["Quota"]
|
||||||
|
if pool_2_user and not pool_2_user == pool_1_user:
|
||||||
|
quota = f"{pool_1_quota}/{pool_2_quota}"
|
||||||
|
|
||||||
|
if pool_1:
|
||||||
|
pool_1 = pool_1.replace("stratum+tcp://", "").replace(
|
||||||
|
"stratum2+tcp://", ""
|
||||||
|
)
|
||||||
|
data.pool_1_url = pool_1
|
||||||
|
|
||||||
|
if pool_1_user:
|
||||||
|
data.pool_1_user = pool_1_user
|
||||||
|
|
||||||
|
if pool_2:
|
||||||
|
pool_2 = pool_2.replace("stratum+tcp://", "").replace(
|
||||||
|
"stratum2+tcp://", ""
|
||||||
|
)
|
||||||
|
data.pool_2_url = pool_2
|
||||||
|
|
||||||
|
if pool_2_user:
|
||||||
|
data.pool_2_user = pool_2_user
|
||||||
|
|
||||||
|
if quota:
|
||||||
|
data.pool_split = str(quota)
|
||||||
|
|
||||||
|
if not mac:
|
||||||
|
try:
|
||||||
|
mac = await self.get_mac()
|
||||||
|
except APIError:
|
||||||
|
logging.info(f"Failed to get mac: {self}")
|
||||||
|
mac = None
|
||||||
|
|
||||||
|
if mac:
|
||||||
|
data.mac = mac
|
||||||
|
|
||||||
|
return data
|
||||||
210
miners/_backends/cgminer.py
Normal file
210
miners/_backends/cgminer.py
Normal file
@@ -0,0 +1,210 @@
|
|||||||
|
import ipaddress
|
||||||
|
import logging
|
||||||
|
|
||||||
|
|
||||||
|
from API.cgminer import CGMinerAPI
|
||||||
|
from miners import BaseMiner
|
||||||
|
from API import APIError
|
||||||
|
|
||||||
|
from data import MinerData
|
||||||
|
|
||||||
|
from settings import MINER_FACTORY_GET_VERSION_RETRIES as DATA_RETRIES
|
||||||
|
|
||||||
|
|
||||||
|
class CGMiner(BaseMiner):
|
||||||
|
def __init__(self, ip: str) -> None:
|
||||||
|
super().__init__(ip)
|
||||||
|
self.ip = ipaddress.ip_address(ip)
|
||||||
|
self.api = CGMinerAPI(ip)
|
||||||
|
self.api_type = "CGMiner"
|
||||||
|
self.uname = "root"
|
||||||
|
self.pwd = "admin"
|
||||||
|
self.config = None
|
||||||
|
|
||||||
|
async def get_model(self):
|
||||||
|
if self.model:
|
||||||
|
return self.model
|
||||||
|
try:
|
||||||
|
version_data = await self.api.devdetails()
|
||||||
|
except APIError:
|
||||||
|
return None
|
||||||
|
if version_data:
|
||||||
|
self.model = version_data["DEVDETAILS"][0]["Model"].replace("Antminer ", "")
|
||||||
|
return self.model
|
||||||
|
return None
|
||||||
|
|
||||||
|
async def get_hostname(self) -> str or None:
|
||||||
|
if self.hostname:
|
||||||
|
return self.hostname
|
||||||
|
try:
|
||||||
|
async with (await self._get_ssh_connection()) as conn:
|
||||||
|
if conn is not None:
|
||||||
|
data = await conn.run("cat /proc/sys/kernel/hostname")
|
||||||
|
host = data.stdout.strip()
|
||||||
|
self.hostname = host
|
||||||
|
return self.hostname
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
except Exception:
|
||||||
|
return None
|
||||||
|
|
||||||
|
async def send_ssh_command(self, cmd):
|
||||||
|
result = None
|
||||||
|
async with (await self._get_ssh_connection()) as conn:
|
||||||
|
for i in range(3):
|
||||||
|
try:
|
||||||
|
result = await conn.run(cmd)
|
||||||
|
result = result.stdout
|
||||||
|
except Exception as e:
|
||||||
|
print(f"{cmd} error: {e}")
|
||||||
|
if i == 3:
|
||||||
|
return
|
||||||
|
continue
|
||||||
|
return result
|
||||||
|
|
||||||
|
async def restart_backend(self) -> bool:
|
||||||
|
return await self.restart_cgminer()
|
||||||
|
|
||||||
|
async def restart_cgminer(self) -> bool:
|
||||||
|
commands = ["cgminer-api restart", "/usr/bin/cgminer-monitor >/dev/null 2>&1"]
|
||||||
|
commands = ";".join(commands)
|
||||||
|
_ret = await self.send_ssh_command(commands)
|
||||||
|
if isinstance(_ret, str):
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
async def reboot(self) -> bool:
|
||||||
|
logging.debug(f"{self}: Sending reboot command.")
|
||||||
|
_ret = await self.send_ssh_command("reboot")
|
||||||
|
logging.debug(f"{self}: Reboot command completed.")
|
||||||
|
if isinstance(_ret, str):
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
async def start_cgminer(self) -> None:
|
||||||
|
commands = [
|
||||||
|
"mkdir -p /etc/tmp/",
|
||||||
|
'echo "*/3 * * * * /usr/bin/cgminer-monitor" > /etc/tmp/root',
|
||||||
|
"crontab -u root /etc/tmp/root",
|
||||||
|
"/usr/bin/cgminer-monitor >/dev/null 2>&1",
|
||||||
|
]
|
||||||
|
commands = ";".join(commands)
|
||||||
|
await self.send_ssh_command(commands)
|
||||||
|
|
||||||
|
async def stop_cgminer(self) -> None:
|
||||||
|
commands = [
|
||||||
|
"mkdir -p /etc/tmp/",
|
||||||
|
'echo "" > /etc/tmp/root',
|
||||||
|
"crontab -u root /etc/tmp/root",
|
||||||
|
"killall cgminer",
|
||||||
|
]
|
||||||
|
commands = ";".join(commands)
|
||||||
|
await self.send_ssh_command(commands)
|
||||||
|
|
||||||
|
async def get_config(self) -> None:
|
||||||
|
async with (await self._get_ssh_connection()) as conn:
|
||||||
|
command = "cat /etc/config/cgminer"
|
||||||
|
result = await conn.run(command, check=True)
|
||||||
|
self.config = result.stdout
|
||||||
|
print(str(self.config))
|
||||||
|
|
||||||
|
async def get_data(self):
|
||||||
|
data = MinerData(ip=str(self.ip), ideal_chips=self.nominal_chips * 3)
|
||||||
|
|
||||||
|
model = await self.get_model()
|
||||||
|
hostname = await self.get_hostname()
|
||||||
|
mac = await self.get_mac()
|
||||||
|
|
||||||
|
if model:
|
||||||
|
data.model = model
|
||||||
|
|
||||||
|
if hostname:
|
||||||
|
data.hostname = hostname
|
||||||
|
|
||||||
|
if mac:
|
||||||
|
data.mac = mac
|
||||||
|
|
||||||
|
miner_data = None
|
||||||
|
for i in range(DATA_RETRIES):
|
||||||
|
miner_data = await self.api.multicommand("summary", "pools", "stats")
|
||||||
|
if miner_data:
|
||||||
|
break
|
||||||
|
|
||||||
|
if not miner_data:
|
||||||
|
return data
|
||||||
|
|
||||||
|
summary = miner_data.get("summary")[0]
|
||||||
|
pools = miner_data.get("pools")[0]
|
||||||
|
stats = miner_data.get("stats")[0]
|
||||||
|
|
||||||
|
if summary:
|
||||||
|
hr = summary.get("SUMMARY")
|
||||||
|
if hr:
|
||||||
|
if len(hr) > 0:
|
||||||
|
hr = hr[0].get("GHS 1m")
|
||||||
|
if hr:
|
||||||
|
data.hashrate = round(hr / 1000, 2)
|
||||||
|
|
||||||
|
if stats:
|
||||||
|
temp = stats.get("STATS")
|
||||||
|
if temp:
|
||||||
|
if len(temp) > 1:
|
||||||
|
data.fan_1 = temp[1].get("fan1")
|
||||||
|
data.fan_2 = temp[1].get("fan2")
|
||||||
|
data.fan_3 = temp[1].get("fan3")
|
||||||
|
data.fan_4 = temp[1].get("fan4")
|
||||||
|
|
||||||
|
board_map = {1: "left_board", 2: "center_board", 3: "right_board"}
|
||||||
|
for item in range(1, 4):
|
||||||
|
board_temp = temp[1].get(f"temp{item}")
|
||||||
|
chip_temp = temp[1].get(f"temp2_{item}")
|
||||||
|
setattr(data, f"{board_map[item]}_chip_temp", chip_temp)
|
||||||
|
setattr(data, f"{board_map[item]}_temp", board_temp)
|
||||||
|
|
||||||
|
if pools:
|
||||||
|
pool_1 = None
|
||||||
|
pool_2 = None
|
||||||
|
pool_1_user = None
|
||||||
|
pool_2_user = None
|
||||||
|
pool_1_quota = 1
|
||||||
|
pool_2_quota = 1
|
||||||
|
quota = 0
|
||||||
|
for pool in pools.get("POOLS"):
|
||||||
|
if not pool_1_user:
|
||||||
|
pool_1_user = pool.get("User")
|
||||||
|
pool_1 = pool["URL"]
|
||||||
|
pool_1_quota = pool["Quota"]
|
||||||
|
elif not pool_2_user:
|
||||||
|
pool_2_user = pool.get("User")
|
||||||
|
pool_2 = pool["URL"]
|
||||||
|
pool_2_quota = pool["Quota"]
|
||||||
|
if not pool.get("User") == pool_1_user:
|
||||||
|
if not pool_2_user == pool.get("User"):
|
||||||
|
pool_2_user = pool.get("User")
|
||||||
|
pool_2 = pool["URL"]
|
||||||
|
pool_2_quota = pool["Quota"]
|
||||||
|
if pool_2_user and not pool_2_user == pool_1_user:
|
||||||
|
quota = f"{pool_1_quota}/{pool_2_quota}"
|
||||||
|
|
||||||
|
if pool_1:
|
||||||
|
pool_1 = pool_1.replace("stratum+tcp://", "").replace(
|
||||||
|
"stratum2+tcp://", ""
|
||||||
|
)
|
||||||
|
data.pool_1_url = pool_1
|
||||||
|
|
||||||
|
if pool_1_user:
|
||||||
|
data.pool_1_user = pool_1_user
|
||||||
|
|
||||||
|
if pool_2:
|
||||||
|
pool_2 = pool_2.replace("stratum+tcp://", "").replace(
|
||||||
|
"stratum2+tcp://", ""
|
||||||
|
)
|
||||||
|
data.pool_2_url = pool_2
|
||||||
|
|
||||||
|
if pool_2_user:
|
||||||
|
data.pool_2_user = pool_2_user
|
||||||
|
|
||||||
|
if quota:
|
||||||
|
data.pool_split = str(quota)
|
||||||
|
|
||||||
|
return data
|
||||||
@@ -1,14 +1,14 @@
|
|||||||
from miners.bmminer import BMMiner
|
from miners._backends import BMMiner
|
||||||
|
import ipaddress
|
||||||
|
|
||||||
|
|
||||||
class HiveonT9(BMMiner):
|
class Hiveon(BMMiner):
|
||||||
def __init__(self, ip: str) -> None:
|
def __init__(self, ip: str) -> None:
|
||||||
super().__init__(ip)
|
super().__init__(ip)
|
||||||
self.model = "T9"
|
self.ip = ipaddress.ip_address(ip)
|
||||||
self.api_type = "Hiveon"
|
self.api_type = "Hiveon"
|
||||||
|
self.uname = "root"
|
||||||
def __repr__(self) -> str:
|
self.pwd = "admin"
|
||||||
return f"HiveonT9: {str(self.ip)}"
|
|
||||||
|
|
||||||
async def get_board_info(self) -> dict:
|
async def get_board_info(self) -> dict:
|
||||||
"""Gets data on each board and chain in the miner."""
|
"""Gets data on each board and chain in the miner."""
|
||||||
3
miners/_types/__init__.py
Normal file
3
miners/_types/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
from .antminer import *
|
||||||
|
from .avalonminer import *
|
||||||
|
from .whatsminer import *
|
||||||
10
miners/_types/antminer/X17/S17.py
Normal file
10
miners/_types/antminer/X17/S17.py
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
from miners import BaseMiner
|
||||||
|
|
||||||
|
|
||||||
|
class S17(BaseMiner):
|
||||||
|
def __init__(self, ip: str):
|
||||||
|
super().__init__()
|
||||||
|
self.ip = ip
|
||||||
|
self.model = "S17"
|
||||||
|
self.nominal_chips = 48
|
||||||
|
self.fan_count = 4
|
||||||
10
miners/_types/antminer/X17/S17_Plus.py
Normal file
10
miners/_types/antminer/X17/S17_Plus.py
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
from miners import BaseMiner
|
||||||
|
|
||||||
|
|
||||||
|
class S17Plus(BaseMiner):
|
||||||
|
def __init__(self, ip: str):
|
||||||
|
super().__init__()
|
||||||
|
self.ip = ip
|
||||||
|
self.model = "S17+"
|
||||||
|
self.nominal_chips = 65
|
||||||
|
self.fan_count = 4
|
||||||
10
miners/_types/antminer/X17/S17_Pro.py
Normal file
10
miners/_types/antminer/X17/S17_Pro.py
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
from miners import BaseMiner
|
||||||
|
|
||||||
|
|
||||||
|
class S17Pro(BaseMiner):
|
||||||
|
def __init__(self, ip: str):
|
||||||
|
super().__init__()
|
||||||
|
self.ip = ip
|
||||||
|
self.model = "S17 Pro"
|
||||||
|
self.nominal_chips = 48
|
||||||
|
self.fan_count = 4
|
||||||
10
miners/_types/antminer/X17/S17e.py
Normal file
10
miners/_types/antminer/X17/S17e.py
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
from miners import BaseMiner
|
||||||
|
|
||||||
|
|
||||||
|
class S17e(BaseMiner):
|
||||||
|
def __init__(self, ip: str):
|
||||||
|
super().__init__()
|
||||||
|
self.ip = ip
|
||||||
|
self.model = "S17e"
|
||||||
|
self.nominal_chips = 135
|
||||||
|
self.fan_count = 4
|
||||||
10
miners/_types/antminer/X17/T17.py
Normal file
10
miners/_types/antminer/X17/T17.py
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
from miners import BaseMiner
|
||||||
|
|
||||||
|
|
||||||
|
class T17(BaseMiner):
|
||||||
|
def __init__(self, ip: str):
|
||||||
|
super().__init__()
|
||||||
|
self.ip = ip
|
||||||
|
self.model = "T17"
|
||||||
|
self.nominal_chips = 30
|
||||||
|
self.fan_count = 4
|
||||||
10
miners/_types/antminer/X17/T17_Plus.py
Normal file
10
miners/_types/antminer/X17/T17_Plus.py
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
from miners import BaseMiner
|
||||||
|
|
||||||
|
|
||||||
|
class T17Plus(BaseMiner):
|
||||||
|
def __init__(self, ip: str):
|
||||||
|
super().__init__()
|
||||||
|
self.ip = ip
|
||||||
|
self.model = "T17+"
|
||||||
|
self.nominal_chips = 44
|
||||||
|
self.fan_count = 4
|
||||||
10
miners/_types/antminer/X17/T17e.py
Normal file
10
miners/_types/antminer/X17/T17e.py
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
from miners import BaseMiner
|
||||||
|
|
||||||
|
|
||||||
|
class T17e(BaseMiner):
|
||||||
|
def __init__(self, ip: str):
|
||||||
|
super().__init__()
|
||||||
|
self.ip = ip
|
||||||
|
self.model = "T17e"
|
||||||
|
self.nominal_chips = 78
|
||||||
|
self.fan_count = 4
|
||||||
8
miners/_types/antminer/X17/__init__.py
Normal file
8
miners/_types/antminer/X17/__init__.py
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
from .S17 import S17
|
||||||
|
from .S17_Plus import S17Plus
|
||||||
|
from .S17_Pro import S17Pro
|
||||||
|
from .S17e import S17e
|
||||||
|
|
||||||
|
from .T17 import T17
|
||||||
|
from .T17_Plus import T17Plus
|
||||||
|
from .T17e import T17e
|
||||||
10
miners/_types/antminer/X19/S19.py
Normal file
10
miners/_types/antminer/X19/S19.py
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
from miners import BaseMiner
|
||||||
|
|
||||||
|
|
||||||
|
class S19(BaseMiner):
|
||||||
|
def __init__(self, ip: str):
|
||||||
|
super().__init__()
|
||||||
|
self.ip = ip
|
||||||
|
self.model = "S19"
|
||||||
|
self.nominal_chips = 76
|
||||||
|
self.fan_count = 4
|
||||||
10
miners/_types/antminer/X19/S19_Pro.py
Normal file
10
miners/_types/antminer/X19/S19_Pro.py
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
from miners import BaseMiner
|
||||||
|
|
||||||
|
|
||||||
|
class S19Pro(BaseMiner):
|
||||||
|
def __init__(self, ip: str):
|
||||||
|
super().__init__()
|
||||||
|
self.ip = ip
|
||||||
|
self.model = "S19 Pro"
|
||||||
|
self.nominal_chips = 114
|
||||||
|
self.fan_count = 4
|
||||||
10
miners/_types/antminer/X19/S19a.py
Normal file
10
miners/_types/antminer/X19/S19a.py
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
from miners import BaseMiner
|
||||||
|
|
||||||
|
|
||||||
|
class S19a(BaseMiner):
|
||||||
|
def __init__(self, ip: str):
|
||||||
|
super().__init__()
|
||||||
|
self.ip = ip
|
||||||
|
self.model = "S19a"
|
||||||
|
self.nominal_chips = 72
|
||||||
|
self.fan_count = 4
|
||||||
10
miners/_types/antminer/X19/S19j.py
Normal file
10
miners/_types/antminer/X19/S19j.py
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
from miners import BaseMiner
|
||||||
|
|
||||||
|
|
||||||
|
class S19j(BaseMiner):
|
||||||
|
def __init__(self, ip: str):
|
||||||
|
super().__init__()
|
||||||
|
self.ip = ip
|
||||||
|
self.model = "S19j"
|
||||||
|
self.nominal_chips = 114
|
||||||
|
self.fan_count = 4
|
||||||
10
miners/_types/antminer/X19/S19j_Pro.py
Normal file
10
miners/_types/antminer/X19/S19j_Pro.py
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
from miners import BaseMiner
|
||||||
|
|
||||||
|
|
||||||
|
class S19jPro(BaseMiner):
|
||||||
|
def __init__(self, ip: str):
|
||||||
|
super().__init__()
|
||||||
|
self.ip = ip
|
||||||
|
self.model = "S19j Pro"
|
||||||
|
self.nominal_chips = 126
|
||||||
|
self.fan_count = 4
|
||||||
10
miners/_types/antminer/X19/T19.py
Normal file
10
miners/_types/antminer/X19/T19.py
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
from miners import BaseMiner
|
||||||
|
|
||||||
|
|
||||||
|
class T19(BaseMiner):
|
||||||
|
def __init__(self, ip: str):
|
||||||
|
super().__init__()
|
||||||
|
self.ip = ip
|
||||||
|
self.model = "T19"
|
||||||
|
self.nominal_chips = 76
|
||||||
|
self.fan_count = 4
|
||||||
9
miners/_types/antminer/X19/__init__.py
Normal file
9
miners/_types/antminer/X19/__init__.py
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
from .S19 import S19
|
||||||
|
from .S19_Pro import S19Pro
|
||||||
|
|
||||||
|
from .S19j import S19j
|
||||||
|
from .S19j_Pro import S19jPro
|
||||||
|
|
||||||
|
from .S19a import S19a
|
||||||
|
|
||||||
|
from .T19 import T19
|
||||||
10
miners/_types/antminer/X9/S9.py
Normal file
10
miners/_types/antminer/X9/S9.py
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
from miners import BaseMiner
|
||||||
|
|
||||||
|
|
||||||
|
class S9(BaseMiner):
|
||||||
|
def __init__(self, ip: str):
|
||||||
|
super().__init__()
|
||||||
|
self.ip = ip
|
||||||
|
self.model = "S9"
|
||||||
|
self.nominal_chips = 63
|
||||||
|
self.fan_count = 2
|
||||||
10
miners/_types/antminer/X9/S9i.py
Normal file
10
miners/_types/antminer/X9/S9i.py
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
from miners import BaseMiner
|
||||||
|
|
||||||
|
|
||||||
|
class S9i(BaseMiner):
|
||||||
|
def __init__(self, ip: str):
|
||||||
|
super().__init__()
|
||||||
|
self.ip = ip
|
||||||
|
self.model = "S9i"
|
||||||
|
self.nominal_chips = 63
|
||||||
|
self.fan_count = 2
|
||||||
10
miners/_types/antminer/X9/T9.py
Normal file
10
miners/_types/antminer/X9/T9.py
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
from miners import BaseMiner
|
||||||
|
|
||||||
|
|
||||||
|
class T9(BaseMiner):
|
||||||
|
def __init__(self, ip: str):
|
||||||
|
super().__init__()
|
||||||
|
self.ip = ip
|
||||||
|
self.model = "T9"
|
||||||
|
self.nominal_chips = 57
|
||||||
|
self.fan_count = 2
|
||||||
3
miners/_types/antminer/X9/__init__.py
Normal file
3
miners/_types/antminer/X9/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
from .S9 import S9
|
||||||
|
from .S9i import S9i
|
||||||
|
from .T9 import T9
|
||||||
3
miners/_types/antminer/__init__.py
Normal file
3
miners/_types/antminer/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
from .X9 import *
|
||||||
|
from .X17 import *
|
||||||
|
from .X19 import *
|
||||||
10
miners/_types/avalonminer/A10X/A1026.py
Normal file
10
miners/_types/avalonminer/A10X/A1026.py
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
from miners import BaseMiner
|
||||||
|
|
||||||
|
|
||||||
|
class Avalon1026(BaseMiner):
|
||||||
|
def __init__(self, ip: str):
|
||||||
|
super().__init__()
|
||||||
|
self.ip = ip
|
||||||
|
self.model = "Avalon 1026"
|
||||||
|
self.nominal_chips = 80
|
||||||
|
self.fan_count = 2
|
||||||
10
miners/_types/avalonminer/A10X/A1047.py
Normal file
10
miners/_types/avalonminer/A10X/A1047.py
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
from miners import BaseMiner
|
||||||
|
|
||||||
|
|
||||||
|
class Avalon1047(BaseMiner):
|
||||||
|
def __init__(self, ip: str):
|
||||||
|
super().__init__()
|
||||||
|
self.ip = ip
|
||||||
|
self.model = "Avalon 1047"
|
||||||
|
self.nominal_chips = 80
|
||||||
|
self.fan_count = 2
|
||||||
10
miners/_types/avalonminer/A10X/A1066.py
Normal file
10
miners/_types/avalonminer/A10X/A1066.py
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
from miners import BaseMiner
|
||||||
|
|
||||||
|
|
||||||
|
class Avalon1066(BaseMiner):
|
||||||
|
def __init__(self, ip: str):
|
||||||
|
super().__init__()
|
||||||
|
self.ip = ip
|
||||||
|
self.model = "Avalon 1066"
|
||||||
|
self.nominal_chips = 114
|
||||||
|
self.fan_count = 4
|
||||||
3
miners/_types/avalonminer/A10X/__init__.py
Normal file
3
miners/_types/avalonminer/A10X/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
from .A1026 import Avalon1026
|
||||||
|
from .A1047 import Avalon1047
|
||||||
|
from .A1066 import Avalon1066
|
||||||
10
miners/_types/avalonminer/A7X/A721.py
Normal file
10
miners/_types/avalonminer/A7X/A721.py
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
from miners import BaseMiner
|
||||||
|
|
||||||
|
|
||||||
|
class Avalon721(BaseMiner):
|
||||||
|
def __init__(self, ip: str):
|
||||||
|
super().__init__()
|
||||||
|
self.ip = ip
|
||||||
|
self.model = "Avalon 721"
|
||||||
|
self.chip_count = 18 # This miner has 4 boards totaling 72
|
||||||
|
self.fan_count = 1 # also only 1 fan
|
||||||
10
miners/_types/avalonminer/A7X/A741.py
Normal file
10
miners/_types/avalonminer/A7X/A741.py
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
from miners import BaseMiner
|
||||||
|
|
||||||
|
|
||||||
|
class Avalon741(BaseMiner):
|
||||||
|
def __init__(self, ip: str):
|
||||||
|
super().__init__()
|
||||||
|
self.ip = ip
|
||||||
|
self.model = "Avalon 741"
|
||||||
|
self.chip_count = 22 # This miner has 4 boards totaling 88
|
||||||
|
self.fan_count = 1 # also only 1 fan
|
||||||
10
miners/_types/avalonminer/A7X/A761.py
Normal file
10
miners/_types/avalonminer/A7X/A761.py
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
from miners import BaseMiner
|
||||||
|
|
||||||
|
|
||||||
|
class Avalon761(BaseMiner):
|
||||||
|
def __init__(self, ip: str):
|
||||||
|
super().__init__()
|
||||||
|
self.ip = ip
|
||||||
|
self.model = "Avalon 761"
|
||||||
|
self.chip_count = 18 # This miner has 4 boards totaling 72
|
||||||
|
self.fan_count = 1 # also only 1 fan
|
||||||
3
miners/_types/avalonminer/A7X/__init__.py
Normal file
3
miners/_types/avalonminer/A7X/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
from .A721 import Avalon721
|
||||||
|
from .A741 import Avalon741
|
||||||
|
from .A761 import Avalon761
|
||||||
10
miners/_types/avalonminer/A8X/A821.py
Normal file
10
miners/_types/avalonminer/A8X/A821.py
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
from miners import BaseMiner
|
||||||
|
|
||||||
|
|
||||||
|
class Avalon821(BaseMiner):
|
||||||
|
def __init__(self, ip: str):
|
||||||
|
super().__init__()
|
||||||
|
self.ip = ip
|
||||||
|
self.model = "Avalon 821"
|
||||||
|
self.chip_count = 26 # This miner has 4 boards totaling 104
|
||||||
|
self.fan_count = 1 # also only 1 fan
|
||||||
10
miners/_types/avalonminer/A8X/A841.py
Normal file
10
miners/_types/avalonminer/A8X/A841.py
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
from miners import BaseMiner
|
||||||
|
|
||||||
|
|
||||||
|
class Avalon841(BaseMiner):
|
||||||
|
def __init__(self, ip: str):
|
||||||
|
super().__init__()
|
||||||
|
self.ip = ip
|
||||||
|
self.model = "Avalon 841"
|
||||||
|
self.chip_count = 26 # This miner has 4 boards totaling 104
|
||||||
|
self.fan_count = 1 # also only 1 fan
|
||||||
10
miners/_types/avalonminer/A8X/A851.py
Normal file
10
miners/_types/avalonminer/A8X/A851.py
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
from miners import BaseMiner
|
||||||
|
|
||||||
|
|
||||||
|
class Avalon851(BaseMiner):
|
||||||
|
def __init__(self, ip: str):
|
||||||
|
super().__init__()
|
||||||
|
self.ip = ip
|
||||||
|
self.model = "Avalon 851"
|
||||||
|
self.chip_count = 26 # This miner has 4 boards totaling 104
|
||||||
|
self.fan_count = 1 # also only 1 fan
|
||||||
3
miners/_types/avalonminer/A8X/__init__.py
Normal file
3
miners/_types/avalonminer/A8X/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
from .A821 import Avalon821
|
||||||
|
from .A841 import Avalon841
|
||||||
|
from .A851 import Avalon851
|
||||||
10
miners/_types/avalonminer/A9X/A921.py
Normal file
10
miners/_types/avalonminer/A9X/A921.py
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
from miners import BaseMiner
|
||||||
|
|
||||||
|
|
||||||
|
class Avalon921(BaseMiner):
|
||||||
|
def __init__(self, ip: str):
|
||||||
|
super().__init__()
|
||||||
|
self.ip = ip
|
||||||
|
self.model = "Avalon 921"
|
||||||
|
self.chip_count = 26 # This miner has 4 boards totaling 104
|
||||||
|
self.fan_count = 1 # also only 1 fan
|
||||||
1
miners/_types/avalonminer/A9X/__init__.py
Normal file
1
miners/_types/avalonminer/A9X/__init__.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
from .A921 import Avalon921
|
||||||
4
miners/_types/avalonminer/__init__.py
Normal file
4
miners/_types/avalonminer/__init__.py
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
from .A7X import *
|
||||||
|
from .A8X import *
|
||||||
|
from .A9X import *
|
||||||
|
from .A10X import *
|
||||||
10
miners/_types/whatsminer/M2X/M20S.py
Normal file
10
miners/_types/whatsminer/M2X/M20S.py
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
from miners import BaseMiner
|
||||||
|
|
||||||
|
|
||||||
|
class M20S(BaseMiner):
|
||||||
|
def __init__(self, ip: str):
|
||||||
|
super().__init__()
|
||||||
|
self.ip = ip
|
||||||
|
self.model = "M20S"
|
||||||
|
self.nominal_chips = 66
|
||||||
|
self.fan_count = 2
|
||||||
10
miners/_types/whatsminer/M2X/M20S_Plus.py
Normal file
10
miners/_types/whatsminer/M2X/M20S_Plus.py
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
from miners import BaseMiner
|
||||||
|
|
||||||
|
|
||||||
|
class M20SPlus(BaseMiner):
|
||||||
|
def __init__(self, ip: str):
|
||||||
|
super().__init__()
|
||||||
|
self.ip = ip
|
||||||
|
self.model = "M20S+"
|
||||||
|
self.nominal_chips = 66
|
||||||
|
self.fan_count = 2
|
||||||
10
miners/_types/whatsminer/M2X/M21.py
Normal file
10
miners/_types/whatsminer/M2X/M21.py
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
from miners import BaseMiner
|
||||||
|
|
||||||
|
|
||||||
|
class M21(BaseMiner):
|
||||||
|
def __init__(self, ip: str):
|
||||||
|
super().__init__()
|
||||||
|
self.ip = ip
|
||||||
|
self.model = "M21"
|
||||||
|
self.nominal_chips = 105
|
||||||
|
self.fan_count = 2
|
||||||
28
miners/_types/whatsminer/M2X/M21S.py
Normal file
28
miners/_types/whatsminer/M2X/M21S.py
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
from miners import BaseMiner
|
||||||
|
|
||||||
|
|
||||||
|
class M21S(BaseMiner):
|
||||||
|
def __init__(self, ip: str):
|
||||||
|
super().__init__()
|
||||||
|
self.ip = ip
|
||||||
|
self.model = "M21S"
|
||||||
|
self.nominal_chips = 66
|
||||||
|
self.fan_count = 2
|
||||||
|
|
||||||
|
|
||||||
|
class M21SV60(BaseMiner):
|
||||||
|
def __init__(self, ip: str):
|
||||||
|
super().__init__()
|
||||||
|
self.ip = ip
|
||||||
|
self.model = "M21S V60"
|
||||||
|
self.nominal_chips = 105
|
||||||
|
self.fan_count = 2
|
||||||
|
|
||||||
|
|
||||||
|
class M21SV20(BaseMiner):
|
||||||
|
def __init__(self, ip: str):
|
||||||
|
super().__init__()
|
||||||
|
self.ip = ip
|
||||||
|
self.model = "M21S V20"
|
||||||
|
self.nominal_chips = 66
|
||||||
|
self.fan_count = 2
|
||||||
10
miners/_types/whatsminer/M2X/M21S_Plus.py
Normal file
10
miners/_types/whatsminer/M2X/M21S_Plus.py
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
from miners import BaseMiner
|
||||||
|
|
||||||
|
|
||||||
|
class M21SPlus(BaseMiner):
|
||||||
|
def __init__(self, ip: str):
|
||||||
|
super().__init__()
|
||||||
|
self.ip = ip
|
||||||
|
self.model = "M21S+"
|
||||||
|
self.nominal_chips = 105
|
||||||
|
self.fan_count = 2
|
||||||
6
miners/_types/whatsminer/M2X/__init__.py
Normal file
6
miners/_types/whatsminer/M2X/__init__.py
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
from .M20S import M20S
|
||||||
|
from .M20S_Plus import M20SPlus
|
||||||
|
|
||||||
|
from .M21 import M21
|
||||||
|
from .M21S import M21S, M21SV20, M21SV60
|
||||||
|
from .M21S_Plus import M21SPlus
|
||||||
46
miners/_types/whatsminer/M3X/M30S.py
Normal file
46
miners/_types/whatsminer/M3X/M30S.py
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
from miners import BaseMiner
|
||||||
|
|
||||||
|
|
||||||
|
class M30S(BaseMiner):
|
||||||
|
def __init__(self, ip: str):
|
||||||
|
super().__init__()
|
||||||
|
self.ip = ip
|
||||||
|
self.model = "M30S"
|
||||||
|
self.nominal_chips = 148
|
||||||
|
self.fan_count = 2
|
||||||
|
|
||||||
|
|
||||||
|
class M30SV50(BaseMiner):
|
||||||
|
def __init__(self, ip: str):
|
||||||
|
super().__init__()
|
||||||
|
self.ip = ip
|
||||||
|
self.model = "M30S V50"
|
||||||
|
self.nominal_chips = 156
|
||||||
|
self.fan_count = 2
|
||||||
|
|
||||||
|
|
||||||
|
class M30SVG20(BaseMiner):
|
||||||
|
def __init__(self, ip: str):
|
||||||
|
super().__init__()
|
||||||
|
self.ip = ip
|
||||||
|
self.model = "M30S VG20"
|
||||||
|
self.nominal_chips = 70
|
||||||
|
self.fan_count = 2
|
||||||
|
|
||||||
|
|
||||||
|
class M30SVE20(BaseMiner):
|
||||||
|
def __init__(self, ip: str):
|
||||||
|
super().__init__()
|
||||||
|
self.ip = ip
|
||||||
|
self.model = "M30S VE20"
|
||||||
|
self.nominal_chips = 111
|
||||||
|
self.fan_count = 2
|
||||||
|
|
||||||
|
|
||||||
|
class M30SVE10(BaseMiner):
|
||||||
|
def __init__(self, ip: str):
|
||||||
|
super().__init__()
|
||||||
|
self.ip = ip
|
||||||
|
self.model = "M30S VE10"
|
||||||
|
self.nominal_chips = 105
|
||||||
|
self.fan_count = 2
|
||||||
37
miners/_types/whatsminer/M3X/M30S_Plus.py
Normal file
37
miners/_types/whatsminer/M3X/M30S_Plus.py
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
from miners import BaseMiner
|
||||||
|
|
||||||
|
|
||||||
|
class M30SPlus(BaseMiner):
|
||||||
|
def __init__(self, ip: str):
|
||||||
|
super().__init__()
|
||||||
|
self.ip = ip
|
||||||
|
self.model = "M30S+"
|
||||||
|
self.nominal_chips = 156
|
||||||
|
self.fan_count = 2
|
||||||
|
|
||||||
|
|
||||||
|
class M30SPlusVG60(BaseMiner):
|
||||||
|
def __init__(self, ip: str):
|
||||||
|
super().__init__()
|
||||||
|
self.ip = ip
|
||||||
|
self.model = "M30S+ VG60"
|
||||||
|
self.nominal_chips = 86
|
||||||
|
self.fan_count = 2
|
||||||
|
|
||||||
|
|
||||||
|
class M30SPlusVE40(BaseMiner):
|
||||||
|
def __init__(self, ip: str):
|
||||||
|
super().__init__()
|
||||||
|
self.ip = ip
|
||||||
|
self.model = "M30S+ VE40"
|
||||||
|
self.nominal_chips = 156
|
||||||
|
self.fan_count = 2
|
||||||
|
|
||||||
|
|
||||||
|
class M30SPlusVF20(BaseMiner):
|
||||||
|
def __init__(self, ip: str):
|
||||||
|
super().__init__()
|
||||||
|
self.ip = ip
|
||||||
|
self.model = "M30S+ VF20"
|
||||||
|
self.nominal_chips = 111
|
||||||
|
self.fan_count = 2
|
||||||
28
miners/_types/whatsminer/M3X/M30S_Plus_Plus.py
Normal file
28
miners/_types/whatsminer/M3X/M30S_Plus_Plus.py
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
from miners import BaseMiner
|
||||||
|
|
||||||
|
|
||||||
|
class M30SPlusPlus(BaseMiner):
|
||||||
|
def __init__(self, ip: str):
|
||||||
|
super().__init__()
|
||||||
|
self.ip = ip
|
||||||
|
self.model = "M30S++"
|
||||||
|
self.nominal_chips = 111
|
||||||
|
self.fan_count = 2
|
||||||
|
|
||||||
|
|
||||||
|
class M30SPlusPlusVG30(BaseMiner):
|
||||||
|
def __init__(self, ip: str):
|
||||||
|
super().__init__()
|
||||||
|
self.ip = ip
|
||||||
|
self.model = "M30S++ V30"
|
||||||
|
self.nominal_chips = 111
|
||||||
|
self.fan_count = 2
|
||||||
|
|
||||||
|
|
||||||
|
class M30SPlusPlusVG40(BaseMiner):
|
||||||
|
def __init__(self, ip: str):
|
||||||
|
super().__init__()
|
||||||
|
self.ip = ip
|
||||||
|
self.model = "M30S++ V40"
|
||||||
|
self.nominal_chips = 117
|
||||||
|
self.fan_count = 2
|
||||||
10
miners/_types/whatsminer/M3X/M31S.py
Normal file
10
miners/_types/whatsminer/M3X/M31S.py
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
from miners import BaseMiner
|
||||||
|
|
||||||
|
|
||||||
|
class M31S(BaseMiner):
|
||||||
|
def __init__(self, ip: str):
|
||||||
|
super().__init__()
|
||||||
|
self.ip = ip
|
||||||
|
self.model = "M31S"
|
||||||
|
# TODO: Add chip count for this miner (per board) - self.nominal_chips
|
||||||
|
self.fan_count = 2
|
||||||
19
miners/_types/whatsminer/M3X/M31S_Plus.py
Normal file
19
miners/_types/whatsminer/M3X/M31S_Plus.py
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
from miners import BaseMiner
|
||||||
|
|
||||||
|
|
||||||
|
class M31SPlus(BaseMiner):
|
||||||
|
def __init__(self, ip: str):
|
||||||
|
super().__init__()
|
||||||
|
self.ip = ip
|
||||||
|
self.model = "M31S+"
|
||||||
|
self.nominal_chips = 78
|
||||||
|
self.fan_count = 2
|
||||||
|
|
||||||
|
|
||||||
|
class M31SPlusVE20(BaseMiner):
|
||||||
|
def __init__(self, ip: str):
|
||||||
|
super().__init__()
|
||||||
|
self.ip = ip
|
||||||
|
self.model = "M31S+ VE20"
|
||||||
|
self.nominal_chips = 78
|
||||||
|
self.fan_count = 2
|
||||||
10
miners/_types/whatsminer/M3X/M32S.py
Normal file
10
miners/_types/whatsminer/M3X/M32S.py
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
from miners import BaseMiner
|
||||||
|
|
||||||
|
|
||||||
|
class M32S(BaseMiner):
|
||||||
|
def __init__(self, ip: str):
|
||||||
|
super().__init__()
|
||||||
|
self.ip = ip
|
||||||
|
self.model = "M32S"
|
||||||
|
self.nominal_chips = 78
|
||||||
|
self.fan_count = 2
|
||||||
8
miners/_types/whatsminer/M3X/__init__.py
Normal file
8
miners/_types/whatsminer/M3X/__init__.py
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
from .M30S import M30S, M30SVE10, M30SVE20, M30SVG20, M30SV50
|
||||||
|
from .M30S_Plus import M30SPlus, M30SPlusVG60, M30SPlusVE40, M30SPlusVF20
|
||||||
|
from .M30S_Plus_Plus import M30SPlusPlus, M30SPlusPlusVG30, M30SPlusPlusVG40
|
||||||
|
|
||||||
|
from .M31S import M31S
|
||||||
|
from .M31S_Plus import M31SPlus, M31SPlusVE20
|
||||||
|
|
||||||
|
from .M32S import M32S
|
||||||
2
miners/_types/whatsminer/__init__.py
Normal file
2
miners/_types/whatsminer/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
from .M2X import *
|
||||||
|
from .M3X import *
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
from miners.bmminer import BMMiner
|
|
||||||
|
|
||||||
|
|
||||||
class BMMinerS9(BMMiner):
|
|
||||||
def __init__(self, ip: str) -> None:
|
|
||||||
super().__init__(ip)
|
|
||||||
self.model = "S9"
|
|
||||||
self.api_type = "BMMiner"
|
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
|
||||||
return f"BMMinerS9: {str(self.ip)}"
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
import logging
|
|
||||||
import toml
|
|
||||||
|
|
||||||
from miners.bosminer import BOSMiner
|
|
||||||
from config.bos import general_config_convert_bos
|
|
||||||
|
|
||||||
|
|
||||||
class BOSMinerS9(BOSMiner):
|
|
||||||
def __init__(self, ip: str) -> None:
|
|
||||||
super().__init__(ip)
|
|
||||||
self.model = "S9"
|
|
||||||
self.api_type = "BOSMiner"
|
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
|
||||||
return f"BOSminerS9: {str(self.ip)}"
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
from miners.cgminer import CGMiner
|
|
||||||
|
|
||||||
|
|
||||||
class CGMinerS9(CGMiner):
|
|
||||||
def __init__(self, ip: str) -> None:
|
|
||||||
super().__init__(ip)
|
|
||||||
self.model = "S9"
|
|
||||||
self.api_type = "CGMiner"
|
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
|
||||||
return f"CGMinerS9: {str(self.ip)}"
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
from miners.bmminer import BMMiner
|
|
||||||
|
|
||||||
|
|
||||||
class BMMinerT9(BMMiner):
|
|
||||||
def __init__(self, ip: str) -> None:
|
|
||||||
super().__init__(ip)
|
|
||||||
self.model = "T9"
|
|
||||||
self.api_type = "BMMiner"
|
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
|
||||||
return f"BMMinerT9: {str(self.ip)}"
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
from miners.cgminer import CGMiner
|
|
||||||
|
|
||||||
|
|
||||||
class CGMinerT9(CGMiner):
|
|
||||||
def __init__(self, ip: str) -> None:
|
|
||||||
super().__init__(ip)
|
|
||||||
self.model = "T9"
|
|
||||||
self.api_type = "CGMiner"
|
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
|
||||||
return f"CGMinerT9: {str(self.ip)}"
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
from miners.bmminer import BMMiner
|
|
||||||
|
|
||||||
|
|
||||||
class BMMinerX17(BMMiner):
|
|
||||||
def __init__(self, ip: str) -> None:
|
|
||||||
super().__init__(ip)
|
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
|
||||||
return f"BMMinerX17: {str(self.ip)}"
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
from miners.bosminer import BOSMiner
|
|
||||||
|
|
||||||
|
|
||||||
class BOSMinerX17(BOSMiner):
|
|
||||||
def __init__(self, ip: str) -> None:
|
|
||||||
super().__init__(ip)
|
|
||||||
self.api_type = "BOSMiner"
|
|
||||||
self.nominal_chips = 65
|
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
|
||||||
return f"BOSminerX17: {str(self.ip)}"
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
from miners.cgminer import CGMiner
|
|
||||||
|
|
||||||
|
|
||||||
class CGMinerX17(CGMiner):
|
|
||||||
def __init__(self, ip: str) -> None:
|
|
||||||
super().__init__(ip)
|
|
||||||
self.api_type = "CGMiner"
|
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
|
||||||
return f"CGMinerX17: {str(self.ip)}"
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
from miners.bmminer import BMMiner
|
|
||||||
import logging
|
|
||||||
|
|
||||||
|
|
||||||
class BMMinerX19(BMMiner):
|
|
||||||
def __init__(self, ip: str) -> None:
|
|
||||||
super().__init__(ip)
|
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
|
||||||
return f"BMMinerX19: {str(self.ip)}"
|
|
||||||
|
|
||||||
async def get_model(self):
|
|
||||||
if self.model:
|
|
||||||
logging.debug(f"Found model for {self.ip}: {self.model}")
|
|
||||||
return self.model
|
|
||||||
version_data = await self.api.version()
|
|
||||||
if version_data:
|
|
||||||
self.model = version_data["VERSION"][0]["Type"].replace("Antminer ", "")
|
|
||||||
logging.debug(f"Found model for {self.ip}: {self.model}")
|
|
||||||
return self.model
|
|
||||||
logging.warning(f"Failed to get model for miner: {self}")
|
|
||||||
return None
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
from miners.bosminer import BOSMiner
|
|
||||||
|
|
||||||
|
|
||||||
class BOSMinerX19(BOSMiner):
|
|
||||||
def __init__(self, ip: str) -> None:
|
|
||||||
super().__init__(ip)
|
|
||||||
self.api_type = "BOSMiner"
|
|
||||||
self.nominal_chips = 114
|
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
|
||||||
return f"BOSminerX19: {str(self.ip)}"
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
from miners.cgminer import CGMiner
|
|
||||||
import logging
|
|
||||||
|
|
||||||
|
|
||||||
class CGMinerX19(CGMiner):
|
|
||||||
def __init__(self, ip: str) -> None:
|
|
||||||
super().__init__(ip)
|
|
||||||
self.api_type = "CGMiner"
|
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
|
||||||
return f"CGMinerX19: {str(self.ip)}"
|
|
||||||
|
|
||||||
async def get_model(self):
|
|
||||||
if self.model:
|
|
||||||
logging.debug(f"Found model for {self.ip}: {self.model}")
|
|
||||||
return self.model
|
|
||||||
version_data = await self.api.version()
|
|
||||||
if version_data:
|
|
||||||
self.model = version_data["VERSION"][0]["Type"].replace("Antminer ", "")
|
|
||||||
logging.debug(f"Found model for {self.ip}: {self.model}")
|
|
||||||
return self.model
|
|
||||||
logging.warning(f"Failed to get model for miner: {self}")
|
|
||||||
return None
|
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
from .bmminer import *
|
||||||
|
from .bosminer import *
|
||||||
|
from .cgminer import *
|
||||||
|
from .hiveon import *
|
||||||
|
|||||||
8
miners/antminer/bmminer/X17/S17.py
Normal file
8
miners/antminer/bmminer/X17/S17.py
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
from .X17 import BMMinerX17
|
||||||
|
from miners._types import S17 # noqa - Ignore access to _module
|
||||||
|
|
||||||
|
|
||||||
|
class BMMinerS17(BMMinerX17, S17):
|
||||||
|
def __init__(self, ip: str) -> None:
|
||||||
|
super().__init__(ip)
|
||||||
|
self.ip = ip
|
||||||
8
miners/antminer/bmminer/X17/S17_Plus.py
Normal file
8
miners/antminer/bmminer/X17/S17_Plus.py
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
from .X17 import BMMinerX17
|
||||||
|
from miners._types import S17Plus # noqa - Ignore access to _module
|
||||||
|
|
||||||
|
|
||||||
|
class BMMinerS17Plus(BMMinerX17, S17Plus):
|
||||||
|
def __init__(self, ip: str) -> None:
|
||||||
|
super().__init__(ip)
|
||||||
|
self.ip = ip
|
||||||
8
miners/antminer/bmminer/X17/S17_Pro.py
Normal file
8
miners/antminer/bmminer/X17/S17_Pro.py
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
from .X17 import BMMinerX17
|
||||||
|
from miners._types import S17Pro # noqa - Ignore access to _module
|
||||||
|
|
||||||
|
|
||||||
|
class BMMinerS17Pro(BMMinerX17, S17Pro):
|
||||||
|
def __init__(self, ip: str) -> None:
|
||||||
|
super().__init__(ip)
|
||||||
|
self.ip = ip
|
||||||
8
miners/antminer/bmminer/X17/S17e.py
Normal file
8
miners/antminer/bmminer/X17/S17e.py
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
from .X17 import BMMinerX17
|
||||||
|
from miners._types import S17e # noqa - Ignore access to _module
|
||||||
|
|
||||||
|
|
||||||
|
class BMMinerS17e(BMMinerX17, S17e):
|
||||||
|
def __init__(self, ip: str) -> None:
|
||||||
|
super().__init__(ip)
|
||||||
|
self.ip = ip
|
||||||
8
miners/antminer/bmminer/X17/T17.py
Normal file
8
miners/antminer/bmminer/X17/T17.py
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
from .X17 import BMMinerX17
|
||||||
|
from miners._types import T17 # noqa - Ignore access to _module
|
||||||
|
|
||||||
|
|
||||||
|
class BMMinerT17(BMMinerX17, T17):
|
||||||
|
def __init__(self, ip: str) -> None:
|
||||||
|
super().__init__(ip)
|
||||||
|
self.ip = ip
|
||||||
8
miners/antminer/bmminer/X17/T17_Plus.py
Normal file
8
miners/antminer/bmminer/X17/T17_Plus.py
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
from .X17 import BMMinerX17
|
||||||
|
from miners._types import T17Plus # noqa - Ignore access to _module
|
||||||
|
|
||||||
|
|
||||||
|
class BMMinerT17Plus(BMMinerX17, T17Plus):
|
||||||
|
def __init__(self, ip: str) -> None:
|
||||||
|
super().__init__(ip)
|
||||||
|
self.ip = ip
|
||||||
8
miners/antminer/bmminer/X17/T17e.py
Normal file
8
miners/antminer/bmminer/X17/T17e.py
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
from .X17 import BMMinerX17
|
||||||
|
from miners._types import T17e # noqa - Ignore access to _module
|
||||||
|
|
||||||
|
|
||||||
|
class BMMinerT17e(BMMinerX17, T17e):
|
||||||
|
def __init__(self, ip: str) -> None:
|
||||||
|
super().__init__(ip)
|
||||||
|
self.ip = ip
|
||||||
83
miners/antminer/bmminer/X17/X17.py
Normal file
83
miners/antminer/bmminer/X17/X17.py
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
from miners._backends import BMMiner # noqa - Ignore access to _module
|
||||||
|
|
||||||
|
import httpx
|
||||||
|
|
||||||
|
|
||||||
|
class BMMinerX17(BMMiner):
|
||||||
|
def __init__(self, ip: str) -> None:
|
||||||
|
super().__init__(ip)
|
||||||
|
self.ip = ip
|
||||||
|
|
||||||
|
async def get_hostname(self) -> str or None:
|
||||||
|
hostname = None
|
||||||
|
url = f"http://{self.ip}/cgi-bin/get_system_info.cgi"
|
||||||
|
auth = httpx.DigestAuth("root", "root")
|
||||||
|
async with httpx.AsyncClient() as client:
|
||||||
|
data = await client.get(url, auth=auth)
|
||||||
|
if data.status_code == 200:
|
||||||
|
data = data.json()
|
||||||
|
if len(data.keys()) > 0:
|
||||||
|
if "hostname" in data.keys():
|
||||||
|
hostname = data["hostname"]
|
||||||
|
return hostname
|
||||||
|
|
||||||
|
async def get_mac(self):
|
||||||
|
mac = None
|
||||||
|
url = f"http://{self.ip}/cgi-bin/get_system_info.cgi"
|
||||||
|
auth = httpx.DigestAuth("root", "root")
|
||||||
|
async with httpx.AsyncClient() as client:
|
||||||
|
data = await client.get(url, auth=auth)
|
||||||
|
if data.status_code == 200:
|
||||||
|
data = data.json()
|
||||||
|
if len(data.keys()) > 0:
|
||||||
|
if "macaddr" in data.keys():
|
||||||
|
mac = data["macaddr"]
|
||||||
|
return mac
|
||||||
|
|
||||||
|
async def fault_light_on(self) -> bool:
|
||||||
|
url = f"http://{self.ip}/cgi-bin/blink.cgi"
|
||||||
|
auth = httpx.DigestAuth("root", "root")
|
||||||
|
async with httpx.AsyncClient() as client:
|
||||||
|
try:
|
||||||
|
await client.post(url, data={"action": "startBlink"}, auth=auth)
|
||||||
|
except httpx.ReadTimeout:
|
||||||
|
# Expected behaviour
|
||||||
|
pass
|
||||||
|
data = await client.post(url, data={"action": "onPageLoaded"}, auth=auth)
|
||||||
|
if data.status_code == 200:
|
||||||
|
data = data.json()
|
||||||
|
if data["isBlinking"]:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
async def fault_light_off(self) -> bool:
|
||||||
|
url = f"http://{self.ip}/cgi-bin/blink.cgi"
|
||||||
|
auth = httpx.DigestAuth("root", "root")
|
||||||
|
async with httpx.AsyncClient() as client:
|
||||||
|
await client.post(url, data={"action": "stopBlink"}, auth=auth)
|
||||||
|
data = await client.post(url, data={"action": "onPageLoaded"}, auth=auth)
|
||||||
|
if data.status_code == 200:
|
||||||
|
data = data.json()
|
||||||
|
if not data["isBlinking"]:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
async def check_light(self):
|
||||||
|
url = f"http://{self.ip}/cgi-bin/blink.cgi"
|
||||||
|
auth = httpx.DigestAuth("root", "root")
|
||||||
|
async with httpx.AsyncClient() as client:
|
||||||
|
data = await client.post(url, data={"action": "onPageLoaded"}, auth=auth)
|
||||||
|
if data.status_code == 200:
|
||||||
|
data = data.json()
|
||||||
|
if data["isBlinking"]:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
async def reboot(self) -> bool:
|
||||||
|
url = f"http://{self.ip}/cgi-bin/reboot.cgi"
|
||||||
|
auth = httpx.DigestAuth("root", "root")
|
||||||
|
async with httpx.AsyncClient() as client:
|
||||||
|
data = await client.get(url, auth=auth)
|
||||||
|
if data.status_code == 200:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
8
miners/antminer/bmminer/X17/__init__.py
Normal file
8
miners/antminer/bmminer/X17/__init__.py
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
from .S17 import BMMinerS17
|
||||||
|
from .S17_Plus import BMMinerS17Plus
|
||||||
|
from .S17_Pro import BMMinerS17Pro
|
||||||
|
from .S17e import BMMinerS17e
|
||||||
|
|
||||||
|
from .T17 import BMMinerT17
|
||||||
|
from .T17_Plus import BMMinerT17Plus
|
||||||
|
from .T17e import BMMinerT17e
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user