Added quality lookup time info to FarmingInfo (#15775)

This commit is contained in:
Izumi Hoshino 2023-07-15 04:23:34 +09:00 committed by GitHub
parent 42a6d1afa6
commit 15fa5f3764
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 14 additions and 5 deletions

View File

@ -532,8 +532,8 @@ class FarmerAPI:
msg = make_msg(ProtocolMessageTypes.request_signatures, request)
await self.farmer.server.send_to_specific([msg], node_id)
@api_request()
async def farming_info(self, request: farmer_protocol.FarmingInfo) -> None:
@api_request(peer_required=True)
async def farming_info(self, request: farmer_protocol.FarmingInfo, peer: WSChiaConnection) -> None:
self.farmer.state_changed(
"new_farming_info",
{
@ -544,6 +544,8 @@ class FarmerAPI:
"proofs": request.proofs,
"total_plots": request.total_plots,
"timestamp": request.timestamp,
"node_id": peer.peer_node_id,
"lookup_time": request.lookup_time,
}
},
)

View File

@ -221,6 +221,7 @@ class HarvesterAPI:
self.harvester.log.debug(f"new_signage_point_harvester {passed} plots passed the plot filter")
# Concurrently executes all lookups on disk, to take advantage of multiple disk parallelism
time_taken = time.time() - start
total_proofs_found = 0
for filename_sublist_awaitable in asyncio.as_completed(awaitables):
filename, sublist = await filename_sublist_awaitable
@ -239,6 +240,7 @@ class HarvesterAPI:
await peer.send_message(msg)
now = uint64(int(time.time()))
farming_info = FarmingInfo(
new_challenge.challenge_hash,
new_challenge.sp_hash,
@ -246,13 +248,14 @@ class HarvesterAPI:
uint32(passed),
uint32(total_proofs_found),
uint32(total),
uint64(time_taken * 1_000_000), # nano seconds,
)
pass_msg = make_msg(ProtocolMessageTypes.farming_info, farming_info)
await peer.send_message(pass_msg)
found_time = time.time() - start
self.harvester.log.info(
f"{len(awaitables)} plots were eligible for farming {new_challenge.challenge_hash.hex()[:10]}..."
f" Found {total_proofs_found} proofs. Time: {found_time:.5f} s. "
f" Found {total_proofs_found} proofs. Time: {time_taken:.5f} s. "
f"Total {self.harvester.plot_manager.plot_count()} plots"
)
self.harvester.state_changed(
@ -262,7 +265,7 @@ class HarvesterAPI:
"total_plots": self.harvester.plot_manager.plot_count(),
"found_proofs": total_proofs_found,
"eligible_plots": len(awaitables),
"time": found_time,
"time": time_taken,
},
)

View File

@ -61,6 +61,7 @@ class FarmingInfo(Streamable):
passed: uint32
proofs: uint32
total_plots: uint32
lookup_time: uint64
@streamable

View File

@ -35,6 +35,7 @@ class HarvesterRpcApi:
if change == "farming_info":
payloads.append(create_payload_dict("farming_info", change_data, self.service_name, "metrics"))
payloads.append(create_payload_dict("farming_info", change_data, self.service_name, "wallet_ui"))
if change == "add_connection":
payloads.append(create_payload_dict("add_connection", change_data, self.service_name, "metrics"))

View File

@ -125,6 +125,7 @@ farming_info = farmer_protocol.FarmingInfo(
uint32(1390832181),
uint32(908923578),
uint32(2259819406),
uint64(3942498),
)
signed_values = farmer_protocol.SignedValues(

View File

@ -49,6 +49,7 @@ farming_info_json: Dict[str, Any] = {
"passed": 1390832181,
"proofs": 908923578,
"total_plots": 2259819406,
"lookup_time": 3942498,
}
signed_values_json: Dict[str, Any] = {