code: private Sha256Hash calculateHash() {
          try {
              ByteArrayOutputStream bos = new UnsafeByteArrayOutputStream(HEADER_SIZE);
              writeHeader(bos);
              return Sha256Hash.wrapReversed(Sha256Hash.hashTwice(bos.toByteArray()));
          } catch (IOException e) {
              throw new RuntimeException(e); // Cannot happen.
          }
      }
docs: Calculates the block hash by serializing the block and hashing the
  resulting bytes.