code: func (idx *AddrIndex) ConnectBlock(dbTx database.Tx, block *btcutil.Block,
  	stxos []blockchain.SpentTxOut) error {
  
  	// The offset and length of the transactions within the serialized
  	// block.
  	txLocs, err := block.TxLoc()
  	if err != nil {
  		return err
  	}
  
  	// Get the internal block ID associated with the block.
  	blockID, err := dbFetchBlockIDByHash(dbTx, block.Hash())
  	if err != nil {
  		return err
  	}
  
  	// Build all of the address to transaction mappings in a local map.
  	addrsToTxns := make(writeIndexData)
  	idx.indexBlock(addrsToTxns, block, stxos)
  
  	// Add all of the index entries for each address.
  	addrIdxBucket := dbTx.Metadata().Bucket(addrIndexKey)
  	for addrKey, txIdxs := range addrsToTxns {
  		for _, txIdx := range txIdxs {
  			err := dbPutAddrIndexEntry(addrIdxBucket, addrKey,
  				blockID, txLocs[txIdx])
  			if err != nil {
  				return err
  			}
  		}
  	}
  
  	return nil
  }
docs: // ConnectBlock is invoked by the index manager when a new block has been
  // connected to the main chain.  This indexer adds a mapping for each address
  // the transactions in the block involve.
  //
  // This is part of the Indexer interface.