コード例 #1
0
        void ProcessReadChunk()
        {
            RequestReadChunk request = RequestReadChunk.Deserialize(ProtocolParser.ReadBytes(input));
            ReplyReadChunk   reply   = new ReplyReadChunk();
            Chunk            c       = localRepo.ReadChunk(ChunkHash.FromHashBytes(request.ChunkHash));

            reply.ChunkData = c.Data;

            ProtocolParser.WriteBytes(output, ReplyReadChunk.SerializeToBytes(reply));
        }
コード例 #2
0
ファイル: PipeRepo.cs プロジェクト: hultqvist/Whisper
        public override Chunk ReadChunk(ChunkHash chunkHash)
        {
            RequestReadChunk msg = new RequestReadChunk();

            msg.ChunkHash = chunkHash.bytes;
            SendMessage(msg);

            ReplyReadChunk reply = ReplyReadChunk.Deserialize(ProtocolParser.ReadBytes(input));
            Chunk          c     = new Chunk(reply.ChunkData);

            //Verify Hash
            if (c.ChunkHash.Equals(chunkHash) == false)
            {
                throw new InvalidDataException("Hash mismatch: " + chunkHash);
            }

            return(c);
        }