public static void write(FileChannel channel, StoredBlock block) throws IOException {
   ByteBuffer buf = ByteBuffer.allocate(Record.SIZE);
   buf.putInt(block.getHeight());
   byte[] chainWorkBytes = block.getChainWork().toByteArray();
   checkState(
       chainWorkBytes.length <= CHAIN_WORK_BYTES, "Ran out of space to store chain work!");
   if (chainWorkBytes.length < CHAIN_WORK_BYTES) {
     // Pad to the right size.
     buf.put(EMPTY_BYTES, 0, CHAIN_WORK_BYTES - chainWorkBytes.length);
   }
   buf.put(chainWorkBytes);
   buf.put(block.getHeader().cloneAsHeader().feathercoinSerialize());
   buf.position(0);
   channel.position(channel.size());
   if (channel.write(buf) < Record.SIZE) throw new IOException("Failed to write record!");
   channel.position(channel.size() - Record.SIZE);
 }