feature: add avalon and goldshell to miner config types.
This commit is contained in:
@@ -58,6 +58,24 @@ class MinerConfig:
|
|||||||
**self.power_scaling.as_am_old(),
|
**self.power_scaling.as_am_old(),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def as_goldshell(self, user_suffix: str = None):
|
||||||
|
return {
|
||||||
|
**self.fan_mode.as_goldshell(),
|
||||||
|
**self.mining_mode.as_goldshell(),
|
||||||
|
**self.pools.as_goldshell(user_suffix=user_suffix),
|
||||||
|
**self.temperature.as_goldshell(),
|
||||||
|
**self.power_scaling.as_goldshell(),
|
||||||
|
}
|
||||||
|
|
||||||
|
def as_avalon(self, user_suffix: str = None):
|
||||||
|
return {
|
||||||
|
**self.fan_mode.as_avalon(),
|
||||||
|
**self.mining_mode.as_avalon(),
|
||||||
|
**self.pools.as_avalon(user_suffix=user_suffix),
|
||||||
|
**self.temperature.as_avalon(),
|
||||||
|
**self.power_scaling.as_avalon(),
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
config = MinerConfig(
|
config = MinerConfig(
|
||||||
@@ -72,6 +90,8 @@ if __name__ == "__main__":
|
|||||||
),
|
),
|
||||||
mining_mode=MiningModeConfig.power_tuning(3000),
|
mining_mode=MiningModeConfig.power_tuning(3000),
|
||||||
)
|
)
|
||||||
print(config.as_wm())
|
print("WM:", config.as_wm())
|
||||||
print(config.as_am_modern())
|
print("AM Modern:", config.as_am_modern())
|
||||||
print(config.as_am_old())
|
print("AM Old:", config.as_am_old())
|
||||||
|
print("GS:", config.as_goldshell())
|
||||||
|
print("Avalon:", config.as_avalon())
|
||||||
|
|||||||
@@ -62,6 +62,20 @@ class Pool(MinerConfigValue):
|
|||||||
f"_ant_pool{idx}pw": self.password,
|
f"_ant_pool{idx}pw": self.password,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def as_goldshell(self, user_suffix: str = None):
|
||||||
|
if user_suffix is not None:
|
||||||
|
return {
|
||||||
|
"url": self.url,
|
||||||
|
"user": f"{self.user}{user_suffix}",
|
||||||
|
"pass": self.password,
|
||||||
|
}
|
||||||
|
return {"url": self.url, "user": self.user, "pass": self.password}
|
||||||
|
|
||||||
|
def as_avalon(self, user_suffix: str = None):
|
||||||
|
if user_suffix is not None:
|
||||||
|
return ",".join([self.url, f"{self.user}{user_suffix}", self.password])
|
||||||
|
return ",".join([self.url, self.user, self.password])
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class PoolGroup(MinerConfigValue):
|
class PoolGroup(MinerConfigValue):
|
||||||
@@ -75,7 +89,7 @@ class PoolGroup(MinerConfigValue):
|
|||||||
random.choice(string.ascii_uppercase + string.digits) for _ in range(6)
|
random.choice(string.ascii_uppercase + string.digits) for _ in range(6)
|
||||||
) # generate random pool group name in case it isn't set
|
) # generate random pool group name in case it isn't set
|
||||||
|
|
||||||
def as_am_modern(self, user_suffix: str = None):
|
def as_am_modern(self, user_suffix: str = None) -> list:
|
||||||
pools = []
|
pools = []
|
||||||
idx = 0
|
idx = 0
|
||||||
while idx < 3:
|
while idx < 3:
|
||||||
@@ -86,7 +100,7 @@ class PoolGroup(MinerConfigValue):
|
|||||||
idx += 1
|
idx += 1
|
||||||
return pools
|
return pools
|
||||||
|
|
||||||
def as_wm(self, user_suffix: str = None):
|
def as_wm(self, user_suffix: str = None) -> dict:
|
||||||
pools = {}
|
pools = {}
|
||||||
idx = 0
|
idx = 0
|
||||||
while idx < 3:
|
while idx < 3:
|
||||||
@@ -99,7 +113,7 @@ class PoolGroup(MinerConfigValue):
|
|||||||
idx += 1
|
idx += 1
|
||||||
return pools
|
return pools
|
||||||
|
|
||||||
def as_am_old(self, user_suffix: str = None):
|
def as_am_old(self, user_suffix: str = None) -> dict:
|
||||||
pools = {}
|
pools = {}
|
||||||
idx = 0
|
idx = 0
|
||||||
while idx < 3:
|
while idx < 3:
|
||||||
@@ -112,6 +126,22 @@ class PoolGroup(MinerConfigValue):
|
|||||||
idx += 1
|
idx += 1
|
||||||
return pools
|
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
|
||||||
|
|
||||||
|
def as_avalon(self, user_suffix: str = None) -> dict:
|
||||||
|
if len(self.pools) > 0:
|
||||||
|
return self.pools[0].as_avalon(user_suffix=user_suffix)
|
||||||
|
return Pool("", "", "").as_avalon()
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class PoolConfig(MinerConfigValue):
|
class PoolConfig(MinerConfigValue):
|
||||||
@@ -130,17 +160,27 @@ class PoolConfig(MinerConfigValue):
|
|||||||
group_pools.append(pool)
|
group_pools.append(pool)
|
||||||
return cls(groups=[PoolGroup(pools=group_pools)])
|
return cls(groups=[PoolGroup(pools=group_pools)])
|
||||||
|
|
||||||
def as_am_modern(self, user_suffix: str = None):
|
def as_am_modern(self, user_suffix: str = None) -> dict:
|
||||||
if len(self.groups) > 0:
|
if len(self.groups) > 0:
|
||||||
return {"pools": self.groups[0].as_am_modern(user_suffix=user_suffix)}
|
return {"pools": self.groups[0].as_am_modern(user_suffix=user_suffix)}
|
||||||
return {"pools": PoolGroup().as_am_modern()}
|
return {"pools": PoolGroup().as_am_modern()}
|
||||||
|
|
||||||
def as_wm(self, user_suffix: str = None):
|
def as_wm(self, user_suffix: str = None) -> dict:
|
||||||
if len(self.groups) > 0:
|
if len(self.groups) > 0:
|
||||||
return {"pools": self.groups[0].as_wm(user_suffix=user_suffix)}
|
return {"pools": self.groups[0].as_wm(user_suffix=user_suffix)}
|
||||||
return {"pools": PoolGroup().as_wm()}
|
return {"pools": PoolGroup().as_wm()}
|
||||||
|
|
||||||
def as_am_old(self, user_suffix: str = None):
|
def as_am_old(self, user_suffix: str = None) -> dict:
|
||||||
if len(self.groups) > 0:
|
if len(self.groups) > 0:
|
||||||
return self.groups[0].as_am_old(user_suffix=user_suffix)
|
return self.groups[0].as_am_old(user_suffix=user_suffix)
|
||||||
return PoolGroup().as_am_old()
|
return PoolGroup().as_am_old()
|
||||||
|
|
||||||
|
def as_goldshell(self, user_suffix: str = None) -> dict:
|
||||||
|
if len(self.groups) > 0:
|
||||||
|
return {"pools": self.groups[0].as_goldshell(user_suffix=user_suffix)}
|
||||||
|
return {"pools": PoolGroup().as_goldshell()}
|
||||||
|
|
||||||
|
def as_avalon(self, user_suffix: str = None) -> dict:
|
||||||
|
if len(self.groups) > 0:
|
||||||
|
return {"pools": self.groups[0].as_avalon(user_suffix=user_suffix)}
|
||||||
|
return {"pools": PoolGroup().as_avalon()}
|
||||||
|
|||||||
Reference in New Issue
Block a user