Exemple #1
0
 public void AddCachedBlock(CCmdCachedBlock cachedBlock, CClient client)
 {
     if (this.m_RuningOK)
     {
         if (client == null)
         {
             CLog.Log(Constants.Log.Verbose, "Cached block de un cliente desconocido");
         }
         if (!this.BlockFailedBefore(cachedBlock))
         {
             CCachedBlock block1 = new CCachedBlock(cachedBlock, client);
             bool         flag1  = false;
             if (block1.Element != null)
             {
                 for (int num1 = 0; num1 < this.m_PendingBlocks.Count; num1++)
                 {
                     if (((((CCachedBlock)this.m_PendingBlocks[num1]).StartOffset == block1.StartOffset) && (((CCachedBlock)this.m_PendingBlocks[num1]).EndOffset == block1.EndOffset)) && (((CCachedBlock)this.m_PendingBlocks[num1]).Key[0] == block1.Key[0]))
                     {
                         flag1 = true;
                         CLog.Log(Constants.Log.Verbose, "Cached block already added");
                         break;
                     }
                 }
                 if (!flag1)
                 {
                     this.m_PendingBlocks.Add(block1);
                 }
             }
         }
     }
 }
Exemple #2
0
 private bool BlockFailedBefore(CCmdCachedBlock cachedBlock)
 {
     if ((this.m_FailedWebcacheBlocks != null) && (this.m_FailedWebcacheBlocks.Count != 0))
     {
         for (int num1 = 0; num1 < this.m_FailedWebcacheBlocks.Count; num1++)
         {
             CCachedBlock block1 = (CCachedBlock)this.m_FailedWebcacheBlocks[num1];
             if (((cachedBlock.StartOffset == block1.StartOffset) && (cachedBlock.EndOffset == block1.EndOffset)) && ((cachedBlock.RemoteKey[0] == block1.Key[0]) && (cachedBlock.RemoteKey[1] == block1.Key[1])))
             {
                 CLog.Log(Constants.Log.Verbose, "Ignored previous failed block");
                 return(true);
             }
         }
     }
     return(false);
 }
Exemple #3
0
 // Methods
 public CCachedBlock(CCmdCachedBlock block, CClient client2)
 {
     this.Element         = CKernel.FilesList[block.FileHash];
     this.StartOffset     = block.StartOffset;
     this.EndOffset       = block.EndOffset;
     this.RealStartOffset = this.StartOffset;
     this.RealEndOffset   = this.EndOffset;
     this.ID = block.Id;
     if (((this.Element == null) || this.Element.File.Completed) || ((this.Element.File.FileStatus != Protocol.FileState.Ready) || !this.Element.File.GetNewBlock(ref this.RealStartOffset, ref this.RealEndOffset)))
     {
         this.Element = null;
         CLog.Log(Constants.Log.Verbose, "Cached block not needed");
     }
     else
     {
         this.Key = block.RemoteKey;
         string text1 = new IPAddress((long)block.IPClient).ToString();
         this.HostPort   = text1 + ":" + block.PortClient.ToString();
         this.IPClient   = block.IPClient;
         this.PortClient = block.PortClient;
     }
 }
        // Methods
        public CCCmdCachedMultiBlockFile(MemoryStream buffer)
        {
            this.Blocks = new ArrayList();
            BinaryReader reader1 = new BinaryReader(buffer);

            this.n = reader1.ReadUInt16();
            uint num1 = reader1.ReadUInt32();

            byte[] buffer1 = reader1.ReadBytes(0x10);
            for (int num2 = 0; num2 < this.n; num2++)
            {
                CCmdCachedBlock block1 = new CCmdCachedBlock();
                block1.IPProxy     = num1;
                block1.IPClient    = reader1.ReadUInt32();
                block1.PortClient  = reader1.ReadUInt16();
                block1.FileHash    = buffer1;
                block1.StartOffset = reader1.ReadUInt32();
                block1.EndOffset   = reader1.ReadUInt32();
                block1.RemoteKey   = reader1.ReadBytes(0x10);
                block1.Id          = reader1.ReadUInt32();
                this.Blocks.Add(block1);
            }
        }