code: func newBlockImporter(db database.DB, r io.ReadSeeker) (*blockImporter, error) {
  	// Create the transaction and address indexes if needed.
  	//
  	// CAUTION: the txindex needs to be first in the indexes array because
  	// the addrindex uses data from the txindex during catchup.  If the
  	// addrindex is run first, it may not have the transactions from the
  	// current block indexed.
  	var indexes []indexers.Indexer
  	if cfg.TxIndex || cfg.AddrIndex {
  		// Enable transaction index if address index is enabled since it
  		// requires it.
  		if !cfg.TxIndex {
  			log.Infof("Transaction index enabled because it is " +
  				"required by the address index")
  			cfg.TxIndex = true
  		} else {
  			log.Info("Transaction index is enabled")
  		}
  		indexes = append(indexes, indexers.NewTxIndex(db))
  	}
  	if cfg.AddrIndex {
  		log.Info("Address index is enabled")
  		indexes = append(indexes, indexers.NewAddrIndex(db, activeNetParams))
  	}
  
  	// Create an index manager if any of the optional indexes are enabled.
  	var indexManager blockchain.IndexManager
  	if len(indexes) > 0 {
  		indexManager = indexers.NewManager(db, indexes)
  	}
  
  	chain, err := blockchain.New(&blockchain.Config{
  		DB:           db,
  		ChainParams:  activeNetParams,
  		TimeSource:   blockchain.NewMedianTime(),
  		IndexManager: indexManager,
  	})
  	if err != nil {
  		return nil, err
  	}
  
  	return &blockImporter{
  		db:           db,
  		r:            r,
  		processQueue: make(chan []byte, 2),
  		doneChan:     make(chan bool),
  		errChan:      make(chan error),
  		quit:         make(chan struct{}),
  		chain:        chain,
  		lastLogTime:  time.Now(),
  	}, nil
  }
docs: // newBlockImporter returns a new importer for the provided file reader seeker
  // and database.