Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions chia/timelord/timelord.py
Original file line number Diff line number Diff line change
Expand Up @@ -989,7 +989,7 @@ async def _do_process_communication(
writer.write(iter_str.encode())
await writer.drain()

# Listen to the client until "STOP" is received.
# Listen to the client until 0-length proof is received.
while True:
try:
data = await reader.readexactly(4)
Expand All @@ -1004,15 +1004,19 @@ async def _do_process_communication(
self.vdf_failures_count += 1
break

if data == b"STOP":
log.debug(f"Stopped client running on ip {ip}.")
async with self.lock:
writer.write(b"ACK")
await writer.drain()
break
try:
# This must be a proof, 4 bytes is length prefix
# 4 bytes is length prefix
length = int.from_bytes(data, "big")

# TODO: remove the magic stop length, retain just 0, after chiavdf is updated
magic_stop_length = int.from_bytes(b"STOP", "big")
if length in {0, magic_stop_length}:
log.debug(f"Stopped client running on ip {ip}.")
async with self.lock:
writer.write(b"ACK")
await writer.drain()
break

proof = await reader.readexactly(length)
stdout_bytes_io: io.BytesIO = io.BytesIO(bytes.fromhex(proof.decode()))
except (
Expand Down
Loading