code: func (mp *TxPool) addOrphan(tx *btcutil.Tx, tag Tag) {
  	// Nothing to do if no orphans are allowed.
  	if mp.cfg.Policy.MaxOrphanTxs <= 0 {
  		return
  	}
  
  	// Limit the number orphan transactions to prevent memory exhaustion.
  	// This will periodically remove any expired orphans and evict a random
  	// orphan if space is still needed.
  	mp.limitNumOrphans()
  
  	mp.orphans[*tx.Hash()] = &orphanTx{
  		tx:         tx,
  		tag:        tag,
  		expiration: time.Now().Add(orphanTTL),
  	}
  	for _, txIn := range tx.MsgTx().TxIn {
  		if _, exists := mp.orphansByPrev[txIn.PreviousOutPoint]; !exists {
  			mp.orphansByPrev[txIn.PreviousOutPoint] =
  				make(map[chainhash.Hash]*btcutil.Tx)
  		}
  		mp.orphansByPrev[txIn.PreviousOutPoint][*tx.Hash()] = tx
  	}
  
  	log.Debugf("Stored orphan transaction %v (total: %d)", tx.Hash(),
  		len(mp.orphans))
  }
docs: // addOrphan adds an orphan transaction to the orphan pool.
  //
  // This function MUST be called with the mempool lock held (for writes).