code: func (c *ChainIndexer) eventLoop(currentHeader *types.Header, events chan ChainHeadEvent, sub event.Subscription) {
  	// Mark the chain indexer as active, requiring an additional teardown
  	atomic.StoreUint32(&c.active, 1)
  
  	defer sub.Unsubscribe()
  
  	// Fire the initial new head event to start any outstanding processing
  	c.newHead(currentHeader.Number.Uint64(), false)
  
  	var (
  		prevHeader = currentHeader
  		prevHash   = currentHeader.Hash()
  	)
  	for {
  		select {
  		case errc := <-c.quit:
  			// Chain indexer terminating, report no failure and abort
  			errc <- nil
  			return
  
  		case ev, ok := <-events:
  			// Received a new event, ensure it's not nil (closing) and update
  			if !ok {
  				errc := <-c.quit
  				errc <- nil
  				return
  			}
  			header := ev.Block.Header()
  			if header.ParentHash != prevHash {
  				// Reorg to the common ancestor if needed (might not exist in light sync mode, skip reorg then)
  				// TODO(karalabe, zsfelfoldi): This seems a bit brittle, can we detect this case explicitly?
  
  				if rawdb.ReadCanonicalHash(c.chainDb, prevHeader.Number.Uint64()) != prevHash {
  					if h := rawdb.FindCommonAncestor(c.chainDb, prevHeader, header); h != nil {
  						c.newHead(h.Number.Uint64(), true)
  					}
  				}
  			}
  			c.newHead(header.Number.Uint64(), false)
  
  			prevHeader, prevHash = header, header.Hash()
  		}
  	}
  }
docs: // eventLoop is a secondary - optional - event loop of the indexer which is only
  // started for the outermost indexer to push chain head events into a processing
  // queue.