feature: add is_mining for vnish.
This commit is contained in:
@@ -74,6 +74,10 @@ VNISH_DATA_LOC = DataLocations(
|
|||||||
"_get_uptime",
|
"_get_uptime",
|
||||||
[RPCAPICommand("rpc_stats", "stats")],
|
[RPCAPICommand("rpc_stats", "stats")],
|
||||||
),
|
),
|
||||||
|
str(DataOptions.IS_MINING): DataFunction(
|
||||||
|
"_is_mining",
|
||||||
|
[WebAPICommand("web_summary", "summary")],
|
||||||
|
),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -215,6 +219,19 @@ class VNish(BMMiner):
|
|||||||
except LookupError:
|
except LookupError:
|
||||||
return fw_ver
|
return fw_ver
|
||||||
|
|
||||||
|
async def _is_mining(self, web_summary: dict = None) -> Optional[bool]:
|
||||||
|
if web_summary is None:
|
||||||
|
web_summary = await self.web.summary()
|
||||||
|
|
||||||
|
if web_summary is not None:
|
||||||
|
try:
|
||||||
|
is_mining = (
|
||||||
|
not web_summary["miner"]["miner_status"]["miner_state"] == "stopped"
|
||||||
|
)
|
||||||
|
return is_mining
|
||||||
|
except LookupError:
|
||||||
|
pass
|
||||||
|
|
||||||
async def get_config(self) -> MinerConfig:
|
async def get_config(self) -> MinerConfig:
|
||||||
try:
|
try:
|
||||||
web_settings = await self.web.settings()
|
web_settings = await self.web.settings()
|
||||||
|
|||||||
Reference in New Issue
Block a user