code: func serializeBestChainState(state bestChainState) []byte {
  	// Calculate the full size needed to serialize the chain state.
  	workSumBytes := state.workSum.Bytes()
  	workSumBytesLen := uint32(len(workSumBytes))
  	serializedLen := chainhash.HashSize + 4 + 8 + 4 + workSumBytesLen
  
  	// Serialize the chain state.
  	serializedData := make([]byte, serializedLen)
  	copy(serializedData[0:chainhash.HashSize], state.hash[:])
  	offset := uint32(chainhash.HashSize)
  	byteOrder.PutUint32(serializedData[offset:], state.height)
  	offset += 4
  	byteOrder.PutUint64(serializedData[offset:], state.totalTxns)
  	offset += 8
  	byteOrder.PutUint32(serializedData[offset:], workSumBytesLen)
  	offset += 4
  	copy(serializedData[offset:], workSumBytes)
  	return serializedData[:]
  }
docs: // serializeBestChainState returns the serialization of the passed block best
  // chain state.  This is data to be stored in the chain state bucket.