Skip to content
Draft
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/hw/hw_vdf_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ void clear_vdf_client(struct vdf_client *client)
void stop_conn(struct vdf_client *client, struct vdf_conn *conn)
{
if (conn->sock >= 0) {
write_data(conn, "STOP", 4);
write_data(conn, "\0\0\0\0", 4);
}
if (conn->vdf.init_done) {
hw_stop_proof(&conn->vdf);
Expand Down
9 changes: 3 additions & 6 deletions src/tl_emu.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
# proof for witness type=0: proof value (100 bytes as compressed form)

# VDF client -> Timelord
# "STOP"
# 0-length

# Timelord -> VDF client
# "ACK"
Expand Down Expand Up @@ -68,18 +68,15 @@ async def read_conn(reader, writer, d, idx, task):
try:
while True:
data = await reader.read(4)
if data == b"STOP":
size = int.from_bytes(data, 'big')
if size == 0:
await send_msg(writer, b"ACK")
print("Closing connection for VDF %d" % (idx,))
clear_conn_idx(idx)
writer.close()
task.cancel()
break

size = int.from_bytes(data, 'big')
if not size:
raise ValueError("Empty proof!")

data = await reader.readexactly(size)
data = bytes.fromhex(data.decode())
iters = int.from_bytes(data[:8], 'big')
Expand Down
2 changes: 1 addition & 1 deletion src/vdf_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ void FinishSession(tcp::socket& sock) {
PrintInfo("Stopped everything! Ready for the next challenge.");

std::lock_guard<std::mutex> lock(socket_mutex);
boost::asio::write(sock, boost::asio::buffer("STOP", 4));
boost::asio::write(sock, boost::asio::buffer("\0\0\0\0", 4));

char ack[5];
memset(ack, 0x00, sizeof(ack));
Expand Down
Loading