private void load() throws IOException {
    // read the sequence number of the block
    long sequenceNumber = readUInt();
    if (sequenceNumber != expectedSequenceNumber) {
      throw new IllegalStateException("Expected sequence number " + expectedSequenceNumber + " got " + sequenceNumber);
    }
    expectedSequenceNumber++;

    // get the block hash
    byte[] hash = new byte[HASH_SIZE];
    readFully(hash);

    // get the length
    long readLength = readUInt();
    if (readLength < 0) {
      throw new IllegalStateException("Got negative length for block");
    }
    // length 0 means end of file
    if (readLength == 0) {
      if (!Arrays.equals(hash, ZERO_HASH)) {
        throw new IllegalStateException("Block hash was not zero on final block");
      }
      done = true;
      return;
    }

    // get the new buffer
    byte[] readBuffer = new byte[(int)readLength];
    readFully(readBuffer);

    md.update(readBuffer);
    if (!Arrays.equals(md.digest(), hash)) {
      throw new IllegalStateException("MD5 check failed while reading HashBlock");
    }
    blockInputStream = new ByteArrayInputStream(readBuffer);
  }
private void load()