diff --git a/src/hw/hw_vdf_client.cpp b/src/hw/hw_vdf_client.cpp index 19d063dd..24a98469 100644 --- a/src/hw/hw_vdf_client.cpp +++ b/src/hw/hw_vdf_client.cpp @@ -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); diff --git a/src/tl_emu.py b/src/tl_emu.py index e707a37f..35965f36 100644 --- a/src/tl_emu.py +++ b/src/tl_emu.py @@ -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" @@ -68,7 +68,8 @@ 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) @@ -76,10 +77,6 @@ async def read_conn(reader, writer, d, idx, task): 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') diff --git a/src/vdf_client.cpp b/src/vdf_client.cpp index f22badc6..cbeca489 100644 --- a/src/vdf_client.cpp +++ b/src/vdf_client.cpp @@ -119,7 +119,7 @@ void FinishSession(tcp::socket& sock) { PrintInfo("Stopped everything! Ready for the next challenge."); std::lock_guard 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));