Example #1
0
 /**
  * @return good
  * @since 0.9.1
  */
 boolean checkPiece(PartialPiece pp) {
   int piece = pp.getPiece();
   byte[] hash;
   try {
     hash = pp.getHash();
   } catch (IOException ioe) {
     // Could be caused by closing a peer connnection
     // we don't want the exception to propagate through
     // to Storage.putPiece()
     _log.warn("Error checking", ioe);
     return false;
   }
   for (int i = 0; i < 20; i++) {
     if (hash[i] != piece_hashes[20 * piece + i]) return false;
   }
   return true;
 }