feature: add AM old and goldshell configs.

This commit is contained in:
Upstream Data
2023-12-10 09:45:34 -07:00
parent bfdfa8a6ab
commit 0399094197
4 changed files with 30 additions and 16 deletions

View File

@@ -108,6 +108,15 @@ class MinerConfig:
fan_mode=FanModeConfig.from_am_modern(web_conf)
)
@classmethod
def from_am_old(cls, web_conf: dict):
return cls.from_am_modern(web_conf)
@classmethod
def from_goldshell(cls, web_conf: dict):
return cls(
pools=PoolConfig.from_am_modern(web_conf),
)
def merge(a: dict, b: dict):

View File

@@ -89,7 +89,6 @@ class Pool(MinerConfigValue):
f"Password{idx}": self.password,
}
def as_bosminer(self, user_suffix: str = None):
if user_suffix is not None:
return {
@@ -105,7 +104,15 @@ class Pool(MinerConfigValue):
@classmethod
def from_am_modern(cls, web_pool: dict):
return cls(url=web_pool["url"], user=web_pool["user"], password=web_pool["pass"])
return cls(
url=web_pool["url"], user=web_pool["user"], password=web_pool["pass"]
)
@classmethod
def from_goldshell(cls, web_pool: dict):
return cls(
url=web_pool["url"], user=web_pool["user"], password=web_pool["pass"]
)
@dataclass
@@ -158,15 +165,7 @@ class PoolGroup(MinerConfigValue):
return pools
def as_goldshell(self, user_suffix: str = None) -> list:
pools = []
idx = 0
while idx < 3:
if len(self.pools) > idx:
pools.append(self.pools[idx].as_am_modern(user_suffix=user_suffix))
else:
pools.append(Pool("", "", "").as_am_modern())
idx += 1
return pools
return [pool.as_goldshell(user_suffix) for pool in self.pools]
def as_avalon(self, user_suffix: str = None) -> dict:
if len(self.pools) > 0:
@@ -211,6 +210,9 @@ class PoolGroup(MinerConfigValue):
pools.append(Pool.from_am_modern(pool))
return cls(pools=pools)
@classmethod
def from_goldshell(cls, web_pools: list):
return cls([Pool.from_goldshell(p) for p in web_pools])
@dataclass
@@ -260,7 +262,6 @@ class PoolConfig(MinerConfigValue):
return self.groups[0].as_inno(user_suffix=user_suffix)
return PoolGroup().as_inno()
def as_bosminer(self, user_suffix: str = None) -> dict:
if len(self.groups) > 0:
return {
@@ -280,3 +281,7 @@ class PoolConfig(MinerConfigValue):
pool_data = web_conf["pools"]
return cls([PoolGroup.from_am_modern(pool_data)])
@classmethod
def from_goldshell(cls, web_pools: list):
return cls([PoolGroup.from_goldshell(web_pools)])

View File

@@ -349,11 +349,11 @@ class AntminerOld(CGMiner):
async def get_config(self) -> MinerConfig:
data = await self.web.get_miner_conf()
if data:
self.config = MinerConfig().from_raw(data)
self.config = MinerConfig.from_am_old(data)
return self.config
async def send_config(self, config: MinerConfig, user_suffix: str = None) -> None:
await self.web.set_miner_conf(config.as_x17(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]:
try:

View File

@@ -64,7 +64,7 @@ class BFGMinerGoldshell(BFGMiner):
self.data_locations = GOLDSHELL_DATA_LOC
async def get_config(self) -> MinerConfig:
return MinerConfig().from_raw(await self.web.pools())
return MinerConfig.from_goldshell(await self.web.pools())
async def send_config(self, config: MinerConfig, user_suffix: str = None) -> None:
pools_data = await self.web.pools()
@@ -80,7 +80,7 @@ class BFGMinerGoldshell(BFGMiner):
self.config = config
# send them back 1 at a time
for pool in config.as_goldshell(user_suffix=user_suffix):
for pool in config.as_goldshell(user_suffix=user_suffix)["pools"]:
await self.web.newpool(
url=pool["url"], user=pool["user"], password=pool["pass"]
)