code: func (hc *HeaderChain) SetHead(head uint64, delFn DeleteCallback) {
  	height := uint64(0)
  
  	if hdr := hc.CurrentHeader(); hdr != nil {
  		height = hdr.Number.Uint64()
  	}
  	batch := hc.chainDb.NewBatch()
  	for hdr := hc.CurrentHeader(); hdr != nil && hdr.Number.Uint64() > head; hdr = hc.CurrentHeader() {
  		hash := hdr.Hash()
  		num := hdr.Number.Uint64()
  		if delFn != nil {
  			delFn(batch, hash, num)
  		}
  		rawdb.DeleteHeader(batch, hash, num)
  		rawdb.DeleteTd(batch, hash, num)
  
  		hc.currentHeader.Store(hc.GetHeader(hdr.ParentHash, hdr.Number.Uint64()-1))
  	}
  	// Roll back the canonical chain numbering
  	for i := height; i > head; i-- {
  		rawdb.DeleteCanonicalHash(batch, i)
  	}
  	batch.Write()
  
  	// Clear out any stale content from the caches
  	hc.headerCache.Purge()
  	hc.tdCache.Purge()
  	hc.numberCache.Purge()
  
  	if hc.CurrentHeader() == nil {
  		hc.currentHeader.Store(hc.genesisHeader)
  	}
  	hc.currentHeaderHash = hc.CurrentHeader().Hash()
  
  	rawdb.WriteHeadHeaderHash(hc.chainDb, hc.currentHeaderHash)
  }
docs: // SetHead rewinds the local chain to a new head. Everything above the new head
  // will be deleted and the new one set.