code: func (h *headerIndex) truncateIndex(newTip *chainhash.Hash, delete bool) error {
  	return walletdb.Update(h.db, func(tx walletdb.ReadWriteTx) error {
  		rootBucket := tx.ReadWriteBucket(indexBucket)
  
  		var tipKey []byte
  
  		// Based on the specified index type of this instance of the
  		// index, we'll grab the key that tracks the tip of the chain
  		// we need to update.
  		switch h.indexType {
  		case Block:
  			tipKey = bitcoinTip
  		case RegularFilter:
  			tipKey = regFilterTip
  		default:
  			return fmt.Errorf("unknown index type: %v", h.indexType)
  		}
  
  		// If the delete flag is set, then we'll also delete this entry
  		// from the database as the primary index (block headers) is
  		// being rolled back.
  		if delete {
  			prevTipHash := rootBucket.Get(tipKey)
  			if err := rootBucket.Delete(prevTipHash); err != nil {
  				return err
  			}
  		}
  
  		// With the now stale entry deleted, we'll update the chain tip
  		// to point to the new hash.
  		return rootBucket.Put(tipKey, newTip[:])
  	})
  }
docs: // truncateIndex truncates the index for a particluar header type by a single
  // header entry. The passed newTip pointer should point to the hash of the new
  // chain tip. Optionally, if the entry is to be deleted as well, then the
  // delete flag should be set to true.