ignore errors with S19 multicommands

This commit is contained in:
UpstreamData
2022-05-30 09:46:05 -06:00
parent 24b037f273
commit 5c850a43a9
2 changed files with 10 additions and 4 deletions

View File

@@ -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,7 +80,7 @@ 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: except APIError:
try: try:
data = {} data = {}
@@ -99,6 +101,7 @@ If you are sure you want to use this command please use API.send_command("{item}
command: str, command: str,
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,6 +146,7 @@ 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]:
if not x19_command:
logging.warning(f"{self.ip}: API Command Error: {validation[1]}") logging.warning(f"{self.ip}: API Command Error: {validation[1]}")
raise APIError(validation[1]) raise APIError(validation[1])

View File

@@ -144,7 +144,9 @@ class BMMiner(BaseMiner):
miner_data = None miner_data = None
for i in range(DATA_RETRIES): for i in range(DATA_RETRIES):
miner_data = await self.api.multicommand("summary", "pools", "stats") miner_data = await self.api.multicommand(
"summary", "pools", "stats", ignore_x19_error=True
)
if miner_data: if miner_data:
break break