bug: fix bosminer config parsing.
This commit is contained in:
@@ -127,7 +127,7 @@ class Pool(MinerConfigValue):
|
|||||||
return cls(
|
return cls(
|
||||||
url=toml_pool_conf["url"],
|
url=toml_pool_conf["url"],
|
||||||
user=toml_pool_conf["user"],
|
user=toml_pool_conf["user"],
|
||||||
password=toml_pool_conf["pass"],
|
password=toml_pool_conf["password"],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -135,7 +135,7 @@ class Pool(MinerConfigValue):
|
|||||||
@dataclass
|
@dataclass
|
||||||
class PoolGroup(MinerConfigValue):
|
class PoolGroup(MinerConfigValue):
|
||||||
pools: list[Pool] = field(default_factory=list)
|
pools: list[Pool] = field(default_factory=list)
|
||||||
quota: int = 1
|
quota: int = None
|
||||||
name: str = None
|
name: str = None
|
||||||
|
|
||||||
def __post_init__(self):
|
def __post_init__(self):
|
||||||
@@ -204,14 +204,15 @@ class PoolGroup(MinerConfigValue):
|
|||||||
|
|
||||||
def as_bosminer(self, user_suffix: str = None) -> dict:
|
def as_bosminer(self, user_suffix: str = None) -> dict:
|
||||||
if len(self.pools) > 0:
|
if len(self.pools) > 0:
|
||||||
return {
|
conf = {
|
||||||
"name": self.name,
|
"name": self.name,
|
||||||
"quota": self.quota,
|
|
||||||
"pool": [
|
"pool": [
|
||||||
pool.as_bosminer(user_suffix=user_suffix) for pool in self.pools
|
pool.as_bosminer(user_suffix=user_suffix) for pool in self.pools
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
return {"name": "Group", "quota": 1, "pool": []}
|
if self.quota is not None:
|
||||||
|
conf["quota"] = self.quota
|
||||||
|
return {"name": "Group", "pool": []}
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_api(cls, api_pool_list: list):
|
def from_api(cls, api_pool_list: list):
|
||||||
@@ -240,7 +241,7 @@ class PoolGroup(MinerConfigValue):
|
|||||||
if toml_group_conf.get("pool") is not None:
|
if toml_group_conf.get("pool") is not None:
|
||||||
return cls(
|
return cls(
|
||||||
name=toml_group_conf["name"],
|
name=toml_group_conf["name"],
|
||||||
quota=toml_group_conf["quota"],
|
quota=toml_group_conf.get("quota"),
|
||||||
pools=[Pool.from_bosminer(p) for p in toml_group_conf["pool"]],
|
pools=[Pool.from_bosminer(p) for p in toml_group_conf["pool"]],
|
||||||
)
|
)
|
||||||
return cls()
|
return cls()
|
||||||
|
|||||||
@@ -85,18 +85,16 @@ class AntminerModern(BMMiner):
|
|||||||
|
|
||||||
async def send_config(self, config: MinerConfig, user_suffix: str = None) -> None:
|
async def send_config(self, config: MinerConfig, user_suffix: str = None) -> None:
|
||||||
self.config = config
|
self.config = config
|
||||||
conf = config.as_am_modern(user_suffix=user_suffix)
|
await self.web.set_miner_conf(config.as_am_modern(user_suffix=user_suffix))
|
||||||
data = await self.web.set_miner_conf(conf)
|
# if data:
|
||||||
|
# if data.get("code") == "M000":
|
||||||
if data:
|
# return
|
||||||
if data.get("code") == "M000":
|
#
|
||||||
return
|
# for i in range(7):
|
||||||
|
# data = await self.get_config()
|
||||||
for i in range(7):
|
# if data == self.config:
|
||||||
data = await self.get_config()
|
# break
|
||||||
if data.as_am_modern() == conf:
|
# await asyncio.sleep(1)
|
||||||
break
|
|
||||||
await asyncio.sleep(1)
|
|
||||||
|
|
||||||
async def fault_light_on(self) -> bool:
|
async def fault_light_on(self) -> bool:
|
||||||
data = await self.web.blink(blink=True)
|
data = await self.web.blink(blink=True)
|
||||||
@@ -353,6 +351,7 @@ class AntminerOld(CGMiner):
|
|||||||
return self.config
|
return self.config
|
||||||
|
|
||||||
async def send_config(self, config: MinerConfig, user_suffix: str = None) -> None:
|
async def send_config(self, config: MinerConfig, user_suffix: str = None) -> None:
|
||||||
|
self.config = config
|
||||||
await self.web.set_miner_conf(config.as_am_old(user_suffix=user_suffix))
|
await self.web.set_miner_conf(config.as_am_old(user_suffix=user_suffix))
|
||||||
|
|
||||||
async def get_mac(self) -> Union[str, None]:
|
async def get_mac(self) -> Union[str, None]:
|
||||||
|
|||||||
@@ -617,7 +617,7 @@ class BOSMiner(BaseMiner):
|
|||||||
offset = 0
|
offset = 0
|
||||||
if 3 in b_names:
|
if 3 in b_names:
|
||||||
offset = 1
|
offset = 1
|
||||||
elif 6 in b_names:
|
elif 6 in b_names or 7 in b_names or 8 in b_names:
|
||||||
offset = 6
|
offset = 6
|
||||||
for hb in boards:
|
for hb in boards:
|
||||||
_id = int(hb["name"]) - offset
|
_id = int(hb["name"]) - offset
|
||||||
|
|||||||
@@ -100,16 +100,17 @@ class CGMinerAvalon(CGMiner):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
async def send_config(self, config: MinerConfig, user_suffix: str = None) -> None:
|
async def send_config(self, config: MinerConfig, user_suffix: str = None) -> None:
|
||||||
self.config = config
|
pass
|
||||||
return None
|
# self.config = config
|
||||||
logging.debug(f"{self}: Sending config.") # noqa - This doesnt work...
|
# return None
|
||||||
conf = config.as_avalon(user_suffix=user_suffix)
|
# logging.debug(f"{self}: Sending config.") # noqa - This doesnt work...
|
||||||
try:
|
# conf = config.as_avalon(user_suffix=user_suffix)
|
||||||
data = await self.api.ascset( # noqa
|
# try:
|
||||||
0, "setpool", f"root,root,{conf}"
|
# data = await self.api.ascset( # noqa
|
||||||
) # this should work but doesn't
|
# 0, "setpool", f"root,root,{conf}"
|
||||||
except APIError:
|
# ) # this should work but doesn't
|
||||||
pass
|
# except APIError:
|
||||||
|
# pass
|
||||||
# return data
|
# return data
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|||||||
Reference in New Issue
Block a user