code: func (ethash *Ethash) Prepare(chain consensus.ChainReader, header *types.Header) error {
  	parent := chain.GetHeader(header.ParentHash, header.Number.Uint64()-1)
  	if parent == nil {
  		return consensus.ErrUnknownAncestor
  	}
  	header.Difficulty = ethash.CalcDifficulty(chain, header.Time, parent)
  	return nil
  }
docs: // Prepare implements consensus.Engine, initializing the difficulty field of a
  // header to conform to the ethash protocol. The changes are done inline.