use get and cheap way to do full backwards compat

This commit is contained in:
John-Paul Compagnone
2024-05-13 21:17:48 -04:00
parent 2cba62e050
commit de5932184f

View File

@@ -299,14 +299,23 @@ class MiningModeHashrateTune(MinerConfigValue):
return {"mode": {"mode": "custom", "tune": "ths", "ths": self.hashrate}} return {"mode": {"mode": "custom", "tune": "ths", "ths": self.hashrate}}
def as_epic(self) -> dict: def as_epic(self) -> dict:
return { ## Ensures both backwards compatibility and vopt algos that don't have throttle
"ptune": { if self.throttle_limit is None or self.throttle_step is None:
"algo": self.algo.as_epic(), return {
"target": self.hashrate, "ptune": {
"min_throttle": self.throttle_limit, "algo": self.algo.as_epic(),
"throttle_step": self.throttle_step, "target": self.hashrate,
}
}
else:
return {
"ptune": {
"algo": self.algo.as_epic(),
"target": self.hashrate,
"min_throttle": self.throttle_limit,
"throttle_step": self.throttle_step,
}
} }
}
def as_mara(self) -> dict: def as_mara(self) -> dict:
return { return {
@@ -429,12 +438,14 @@ class MiningModeConfig(MinerConfigOption):
if tuner_running: if tuner_running:
algo_info = web_conf["PerpetualTune"]["Algorithm"] algo_info = web_conf["PerpetualTune"]["Algorithm"]
if algo_info.get("VoltageOptimizer") is not None: if algo_info.get("VoltageOptimizer") is not None:
throttle_limit = algo_info["VoltageOptimizer"].get(
"Min Throttle Target"
)
throttle_step = algo_info["VoltageOptimizer"].get("Throttle Step")
return cls.hashrate_tuning( return cls.hashrate_tuning(
hashrate=algo_info["VoltageOptimizer"]["Target"], hashrate=algo_info["VoltageOptimizer"]["Target"],
throttle_limit=algo_info["VoltageOptimizer"][ throttle_limit=throttle_limit,
"Min Throttle Target" throttle_step=throttle_step,
],
throttle_step=algo_info["VoltageOptimizer"]["Throttle Step"],
algo=TunerAlgo.voltage_optimizer, algo=TunerAlgo.voltage_optimizer,
) )
else: else: