code: func (bc *BlockChain) ExportN(w io.Writer, first uint64, last uint64) error {
  	bc.chainmu.RLock()
  	defer bc.chainmu.RUnlock()
  
  	if first > last {
  		return fmt.Errorf("export failed: first (%d) is greater than last (%d)", first, last)
  	}
  	log.Info("Exporting batch of blocks", "count", last-first+1)
  
  	start, reported := time.Now(), time.Now()
  	for nr := first; nr <= last; nr++ {
  		block := bc.GetBlockByNumber(nr)
  		if block == nil {
  			return fmt.Errorf("export failed on #%d: not found", nr)
  		}
  		if err := block.EncodeRLP(w); err != nil {
  			return err
  		}
  		if time.Since(reported) >= statsReportLimit {
  			log.Info("Exporting blocks", "exported", block.NumberU64()-first, "elapsed", common.PrettyDuration(time.Since(start)))
  			reported = time.Now()
  		}
  	}
  	return nil
  }
docs: // ExportN writes a subset of the active chain to the given writer.