Package org.jmule.core.edonkey

Examples of org.jmule.core.edonkey.PartHashSet


               
            }
           
            hashset.rewind();
                      
            fileHashSet = new PartHashSet(new FileHash(hashes[0]));
           
            for(int j=1; j < hashes.length;j++){
             
              if(stop) return;
             
View Full Code Here


   
    partFile.setGapList(gapList);
   
    if (hashSet==null) {
      hasHashSet = false;
      this.hashSet = new PartHashSet(fileHash);
    } else
      hasHashSet = true;

    checkedParts = new boolean[Misc.getPartCount(fileSize)];
   
View Full Code Here

  /**
   * @return true - file is ok !
   */
  public boolean checkFullFileIntegrity() {
    if (length()<PARTSIZE) {
      PartHashSet newSet = MD4FileHasher.calcHashSets(writeChannel);
      System.out.println(length() + "  \nNew hash : " + newSet.getFileHash());
      System.out.println("hash : " + getFileHash());
      if (newSet.getFileHash().equals(getFileHash()))
        return true;
      this.partFile.getGapList().addGap(0, length());
      return false;
    }
    if (!hasHashSet()) return false;
   
    PartHashSet fileHashSet = partFile.getFileHashSet();
    PartHashSet newSet = MD4FileHasher.calcHashSets(writeChannel);

    if (newSet.size()!=fileHashSet.size())
      return false;
   
    for(int i = 0;i<fileHashSet.size();i++) {
     
      byte b[] = newSet.get(i);
     
      byte a[] = fileHashSet.get(i);
       
     
     
      if (!Arrays.equals(a, b)) {
       
        long begin = PARTSIZE*i;
       
        long end = PARTSIZE*(i+1)-1;
       
        if (end>length()) end = length();
       
        //Adding gap
       
        this.partFile.getGapList().addGap(begin,end);
     
        return false;
      }
     
    }
   
    if (!newSet.getFileHash().equals(fileHashSet.getFileHash())) {
     
      partFile.getGapList().addGap(0, length());
     
      return false;
     
View Full Code Here

            for (int j = 1; j < hashes.length; j++) {
                hashset.get(hashes[j]);
            }
            hashset.rewind();
                      
            PartHashSet fileHashSet = new PartHashSet(new FileHash(hashes[0]));
            for(int j=1; j < hashes.length;j++){
              fileHashSet.add(hashes[j]);
            }
            return fileHashSet;
           
        } catch (Throwable e) {e.printStackTrace();}
    return null;
View Full Code Here

        case OP_HASHSETANSWER: {
          byte[] file_hash = new byte[16];
          packet_data.get(file_hash);
          int partCount = Convert.shortToInt(packet_data.getShort());
          PartHashSet partSet = new PartHashSet(new FileHash(
              file_hash));
          byte[] partHash = new byte[16];

          for (short i = 1; i <= partCount; i++) {
            packet_data.get(partHash);
            partSet.add(partHash);
          }
          _network_manager.receivedHashSetResponseFromPeer(peerIP,
              peerPort, partSet);
          break;
        }
View Full Code Here

      try {
        readChannel = new RandomAccessFile(file,"rws").getChannel();
      } catch (FileNotFoundException e) {
        throw new SharedFileException("Shared file not found");
      }
    PartHashSet newSets = MD4FileHasher.calcHashSets(readChannel);
    hashSet = newSets;
  }
View Full Code Here

      FileHash fileHash = new FileHash(data.array());
   
      data = Misc.getByteBuffer(2);
      fileChannel.read(data);
      int partCount = data.getShort(0);
      PartHashSet partHash = new PartHashSet(fileHash);
   
      for(int i = 0;i<partCount;i++) {
        data = Misc.getByteBuffer(16);
        fileChannel.read(data);
        partHash.add(data.array());
      }
   
      known_met_entity.setPartHashSet(partHash);
   
      data = Misc.getByteBuffer(4);
View Full Code Here

     
      //Load file hash
      data = Misc.getByteBuffer(16);
      fileChannel.read(data);
      fileHash = new FileHash(data.array());
      fileHashSet = new PartHashSet(fileHash);
     
      //Read part count
      data = Misc.getByteBuffer(2);
      fileChannel.read(data);
      short partCount = data.getShort(0);
View Full Code Here

TOP

Related Classes of org.jmule.core.edonkey.PartHashSet

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.