code: void getBlockCrc(DataInputStream in, VersionAndOpcode versionAndOpcode)
        throws IOException {
      // header
      BlockChecksumHeader blockChecksumHeader =
          new BlockChecksumHeader(versionAndOpcode);
      blockChecksumHeader.readFields(in);
      final int namespaceId = blockChecksumHeader.getNamespaceId();
      final Block block = new Block(blockChecksumHeader.getBlockId(), 0,
              blockChecksumHeader.getGenStamp());
  
      DataOutputStream out = null;
  
      ReplicaToRead ri = datanode.data.getReplicaToRead(namespaceId, block);
      if (ri == null) {
        throw new IOException("Unknown block");
      }
  
      updateCurrentThreadName("getting CRC checksum for block " + block);
  
      try {
        //write reply
        out = new DataOutputStream(
            NetUtils.getOutputStream(s, datanode.socketWriteTimeout));
        int blockCrc;
        if (ri.hasBlockCrcInfo()) {
          // There is actually a short window that the block is reopened
          // and we got exception when call getBlockCrc but it's OK. It's
          // only happens for append(). So far we don't optimize for this
          // use case. We can do it later when necessary.
          //
          blockCrc = ri.getBlockCrc();
        } else {
          try {
            if (ri.isInlineChecksum()) {
              blockCrc = BlockInlineChecksumReader.getBlockCrc(datanode, ri,
                  namespaceId, block);
            } else {
              blockCrc = BlockWithChecksumFileReader.getBlockCrc(datanode, ri,
                  namespaceId, block);
            }
          } catch (IOException ioe) {
            LOG.warn("Exception when getting Block CRC", ioe);
            out.writeShort(DataTransferProtocol.OP_STATUS_ERROR);
            out.flush();
            throw ioe;
          }
        }
        
        out.writeShort(DataTransferProtocol.OP_STATUS_SUCCESS);
        out.writeLong(blockCrc);
        out.flush();
      } finally {
        IOUtils.closeStream(out);
      }
    }
docs: Get block data's CRC32 checksum.
  @param in
  @param versionAndOpcode