aboutsummaryrefslogtreecommitdiff
path: root/src/zenhorde/hordeagentmessage.cpp
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2026-04-05 11:45:48 +0200
committerStefan Boberg <[email protected]>2026-04-05 11:45:48 +0200
commit57d7e91c2e0ac4c8fa84b5e91bef5f70c96c6a64 (patch)
tree7f6dd596d49d29a9a0542d8f1332da4196d3d802 /src/zenhorde/hordeagentmessage.cpp
parentdisable zencompute in bundle step (diff)
downloadzen-57d7e91c2e0ac4c8fa84b5e91bef5f70c96c6a64.tar.xz
zen-57d7e91c2e0ac4c8fa84b5e91bef5f70c96c6a64.zip
add WriteCompressedFile RPC for compressed file transfers to HordeAgent
Implements the client/initiator side of the WriteCompressedFile protocol, enabling efficient file uploads to Horde agents with IoHash-based caching. The agent can skip data transfer entirely on cache hits, and files are sent as chunked compressed buffer (.ucb) streams on cache misses.
Diffstat (limited to 'src/zenhorde/hordeagentmessage.cpp')
-rw-r--r--src/zenhorde/hordeagentmessage.cpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/zenhorde/hordeagentmessage.cpp b/src/zenhorde/hordeagentmessage.cpp
index 998134a96..541fd8851 100644
--- a/src/zenhorde/hordeagentmessage.cpp
+++ b/src/zenhorde/hordeagentmessage.cpp
@@ -131,6 +131,34 @@ AgentMessageChannel::Blob(const uint8_t* Data, size_t Length)
}
}
+void
+AgentMessageChannel::SendWriteCompressedFile(std::string_view Path, int64_t CompressedSize, const IoHash& UncompressedHash)
+{
+ const size_t MaxLength = MeasureUnsignedVarInt(Path.size()) + Path.size() + sizeof(int64_t) + sizeof(UncompressedHash.Hash);
+ CreateMessage(AgentMessageType::WriteCompressedFile, MaxLength);
+ WriteString(Path);
+ WriteInt64(CompressedSize);
+ WriteFixedLengthBytes(UncompressedHash.Hash, sizeof(UncompressedHash.Hash));
+ FlushMessage();
+}
+
+void
+AgentMessageChannel::SendWriteCompressedFileData(int32_t Offset, const uint8_t* Data, size_t Length)
+{
+ CreateMessage(AgentMessageType::WriteCompressedFileData, sizeof(int32_t) + Length);
+ WriteInt32(Offset);
+ WriteFixedLengthBytes(Data, Length);
+ FlushMessage();
+}
+
+bool
+AgentMessageChannel::ReadWriteCompressedFileResponse()
+{
+ assert(m_ResponseType == AgentMessageType::WriteCompressedFileResponse);
+ assert(m_ResponseLength >= 1);
+ return m_ResponseData[0] != 0;
+}
+
AgentMessageType
AgentMessageChannel::ReadResponse(int32_t TimeoutMs, bool* OutTimedOut)
{
@@ -229,6 +257,21 @@ AgentMessageChannel::ReadInt32(const uint8_t** Pos)
}
void
+AgentMessageChannel::WriteInt64(int64_t Value)
+{
+ WriteFixedLengthBytes(reinterpret_cast<const uint8_t*>(&Value), sizeof(int64_t));
+}
+
+int64_t
+AgentMessageChannel::ReadInt64(const uint8_t** Pos)
+{
+ int64_t Value;
+ memcpy(&Value, *Pos, sizeof(int64_t));
+ *Pos += sizeof(int64_t);
+ return Value;
+}
+
+void
AgentMessageChannel::WriteFixedLengthBytes(const uint8_t* Data, size_t Length)
{
assert(m_RequestSize + Length <= m_MaxRequestSize);