예제 #1
0
 public override ChunkHash GetCustomHash(CustomID id)
 {
     string idPath = Path.Combine (idRoot, id.ToString () + ".id");
     if (File.Exists (idPath) == false)
         return null;
     byte[] hash = File.ReadAllBytes (idPath);
     return ChunkHash.FromHashBytes (hash);
 }
예제 #2
0
 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));
     }
 }
예제 #3
0
        public override ChunkHash GetCustomHash(CustomID id)
        {
            string idPath = Path.Combine(idRoot, id.ToString() + ".id");

            if (File.Exists(idPath) == false)
            {
                return(null);
            }
            byte[] hash = File.ReadAllBytes(idPath);
            return(ChunkHash.FromHashBytes(hash));
        }
예제 #4
0
        public override ChunkHash GetCustomHash(CustomID customID)
        {
            RequestCustomHash msg = new RequestCustomHash();

            msg.CustomID = customID.bytes;
            SendMessage(msg);

            byte[] rbytes = ProtocolParser.ReadBytes(input);

            //Console.WriteLine("Got reply " + rbytes.Length);

            ReplyCustomHash reply = ReplyCustomHash.Deserialize(rbytes);

            //Console.WriteLine("Got reply " + reply);

            return(ChunkHash.FromHashBytes(reply.ChunkHash));
        }
예제 #5
0
        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);
        }
예제 #6
0
 public override ChunkHash GetCustomHash(CustomID customID)
 {
     //foreach (Storage s in repos)
     throw new System.NotImplementedException();
 }
예제 #7
0
 public override ChunkHash GetCustomHash(CustomID customID)
 {
     return(backend.GetCustomHash(customID));
 }