code: func (b *Broadcaster) rebroadcast() {
  	if len(b.transactions) == 0 {
  		return
  	}
  
  	sortedTxs := wtxmgr.DependencySort(b.transactions)
  	for _, tx := range sortedTxs {
  		err := b.cfg.Broadcast(tx)
  		switch {
  		// If the transaction has already confirmed on-chain, we can
  		// stop broadcasting it further.
  		//
  		// TODO(wilmer); This should ideally be implemented by checking
  		// the chain ourselves rather than trusting our peers.
  		case IsBroadcastError(err, Confirmed):
  			log.Debugf("Re-broadcast of txid=%v, now confirmed!",
  				tx.TxHash())
  
  			delete(b.transactions, tx.TxHash())
  			continue
  
  		// If the transaction already exists within our peers' mempool,
  		// we'll continue to rebroadcast it to ensure it actually
  		// propagates throughout the network.
  		//
  		// TODO(wilmer): Rate limit peers that have already accepted our
  		// transaction into their mempool to prevent resending to them
  		// every time.
  		case IsBroadcastError(err, Mempool):
  			log.Debugf("Re-broadcast of txid=%v, still "+
  				"pending...", tx.TxHash())
  
  			continue
  
  		case err != nil:
  			log.Errorf("Unable to rebroadcast transaction %v: %v",
  				tx.TxHash(), err)
  			continue
  		}
  	}
  }
docs: // rebroadcast rebroadcasts all of the currently pending transactions. Care has
  // been taken to ensure that the transactions are sorted in their dependency
  // order to prevent peers from deeming our transactions as invalid due to
  // broadcasting them before their pending dependencies.