func (tp *TransactionPool) Unsubscribe(subscriber modules.TransactionPoolSubscriber) {
	tp.mu.Lock()
	defer tp.mu.Unlock()
	for i := range tp.subscribers {
		if tp.subscribers[i] == subscriber {
			tp.subscribers = append(tp.subscribers[0:i], tp.subscribers[i+1:]...)
			break
		}
	}
}
Unsubscribe removes a subscriber from the transaction pool. If the
subscriber is not in tp.subscribers, Unsubscribe does nothing. If the
subscriber occurs more than once in tp.subscribers, only the earliest
occurrence is removed (unsubscription fails).
package transactionpool
import (
	"github.com/NebulousLabs/Sia/build"
	"github.com/NebulousLabs/Sia/encoding"
	"github.com/NebulousLabs/Sia/modules"
	"github.com/NebulousLabs/Sia/types"
)
func (tp *TransactionPool) updateSubscribersTransactions() {
	diff := new(modules.TransactionPoolDiff)
	for id := range tp.subscriberSets {
		_, exists := tp.transactionSets[id]
		if exists {
			continue
		}
		diff.RevertedTransactions = append(diff.RevertedTransactions, modules.TransactionSetID(id))
	}
	for _, revert := range diff.RevertedTransactions {
		delete(tp.subscriberSets, TransactionSetID(revert))
	}
	for id, set := range tp.transactionSets {
		_, exists := tp.subscriberSets[id]
		if exists {
			continue
		}
		ids := make([]types.TransactionID, 0, len(set))
		sizes := make([]uint64, 0, len(set))
		for i := range set {
			encodedTxn := encoding.Marshal(set[i])
			sizes = append(sizes, uint64(len(encodedTxn)))
			ids = append(ids, set[i].ID())
		}
		ut := &modules.UnconfirmedTransactionSet{
			Change: tp.transactionSetDiffs[id],
			ID:     modules.TransactionSetID(id),
			IDs:          ids,
			Sizes:        sizes,
			Transactions: set,
		}
		tp.subscriberSets[id] = ut
		diff.AppliedTransactions = append(diff.AppliedTransactions, ut)
	}
	for _, subscriber := range tp.subscribers {
		subscriber.ReceiveUpdatedUnconfirmedTransactions(diff)
	}
}
func (tp *TransactionPool) TransactionPoolSubscribe(subscriber modules.TransactionPoolSubscriber) {
	tp.mu.Lock()
	defer tp.mu.Unlock()
	for _, s := range tp.subscribers {
		if s == subscriber {
			build.Critical("refusing to double-subscribe subscriber")
		}
	}
	tp.subscribers = append(tp.subscribers, subscriber)
	diff := new(modules.TransactionPoolDiff)
	diff.AppliedTransactions = make([]*modules.UnconfirmedTransactionSet, 0, len(tp.subscriberSets))
	for _, ut := range tp.subscriberSets {
		diff.AppliedTransactions = append(diff.AppliedTransactions, ut)
	}
	subscriber.ReceiveUpdatedUnconfirmedTransactions(diff)
}