public CustomID GetID(Chunk chunk) { using (MemoryStream ms = new MemoryStream()) { ms.Write(keyBuffer, 0, keyBuffer.Length); ProtocolParser.WriteBytes(ms, chunk.ClearHash.bytes); return(CustomID.FromBytes(Hash.ComputeHash(ms.ToArray()).bytes)); } }
void ProcessGetCustomHash() { RequestCustomHash request = RequestCustomHash.Deserialize(ProtocolParser.ReadBytes(input)); ReplyCustomHash reply = new ReplyCustomHash(); ChunkHash ch = localRepo.GetCustomHash(CustomID.FromBytes(request.CustomID)); if (ch == null) { reply.ChunkHash = null; } else { reply.ChunkHash = ch.bytes; } //Console.Error.WriteLine("PipeServer: Sending: " + reply); byte[] rbytes = ReplyCustomHash.SerializeToBytes(reply); //Console.Error.WriteLine("PipeServer: Sending: " + rbytes.Length + ", " + BitConverter.ToString(rbytes)); ProtocolParser.WriteBytes(output, rbytes); }