From deca4cfe4453b4ff71626b3fe096c07a3dad7647 Mon Sep 17 00:00:00 2001 From: Wilmer Paulino Date: Fri, 5 Oct 2018 02:07:55 -0700 Subject: [PATCH] chainntnfs/neutrinonotify: remove old spend notification handling logic In this commit, we remove the old spend notification logic within the NeutrinoNotifier as it's been phased out by the TxNotifier. --- chainntnfs/neutrinonotify/neutrino.go | 55 --------------------------- 1 file changed, 55 deletions(-) diff --git a/chainntnfs/neutrinonotify/neutrino.go b/chainntnfs/neutrinonotify/neutrino.go index 9a2d5d76..494ca92b 100644 --- a/chainntnfs/neutrinonotify/neutrino.go +++ b/chainntnfs/neutrinonotify/neutrino.go @@ -68,8 +68,6 @@ type NeutrinoNotifier struct { notificationCancels chan interface{} notificationRegistry chan interface{} - spendNotifications map[wire.OutPoint]map[uint64]*spendNotification - txNotifier *chainntnfs.TxNotifier blockEpochClients map[uint64]*blockEpochRegistration @@ -109,8 +107,6 @@ func New(node *neutrino.ChainService, spendHintCache chainntnfs.SpendHintCache, blockEpochClients: make(map[uint64]*blockEpochRegistration), - spendNotifications: make(map[wire.OutPoint]map[uint64]*spendNotification), - p2pNode: node, rescanErr: make(chan error), @@ -196,11 +192,6 @@ func (n *NeutrinoNotifier) Stop() error { // Notify all pending clients of our shutdown by closing the related // notification channels. - for _, spendClients := range n.spendNotifications { - for _, spendClient := range spendClients { - close(spendClient.spendChan) - } - } for _, epochClient := range n.blockEpochClients { close(epochClient.cancelChan) epochClient.wg.Wait() @@ -264,19 +255,6 @@ out: select { case cancelMsg := <-n.notificationCancels: switch msg := cancelMsg.(type) { - case *spendCancel: - chainntnfs.Log.Infof("Cancelling spend "+ - "notification for out_point=%v, "+ - "spend_id=%v", msg.op, msg.spendID) - - // Before we attempt to close the spendChan, - // ensure that the notification hasn't already - // yet been dispatched. - if outPointClients, ok := n.spendNotifications[msg.op]; ok { - close(outPointClients[msg.spendID].spendChan) - delete(n.spendNotifications[msg.op], msg.spendID) - } - case *epochCancel: chainntnfs.Log.Infof("Cancelling epoch "+ "notification, epoch_id=%v", msg.epochID) @@ -304,17 +282,6 @@ out: case registerMsg := <-n.notificationRegistry: switch msg := registerMsg.(type) { - case *spendNotification: - chainntnfs.Log.Infof("New spend subscription: "+ - "utxo=%v, height_hint=%v", - msg.targetOutpoint, msg.heightHint) - op := *msg.targetOutpoint - - if _, ok := n.spendNotifications[op]; !ok { - n.spendNotifications[op] = make(map[uint64]*spendNotification) - } - n.spendNotifications[op][msg.spendID] = msg - case *chainntnfs.HistoricalConfDispatch: // Look up whether the transaction is already // included in the active chain. We'll do this @@ -659,28 +626,6 @@ func (n *NeutrinoNotifier) notifyBlockEpochClient(epochClient *blockEpochRegistr } } -// spendNotification couples a target outpoint along with the channel used for -// notifications once a spend of the outpoint has been detected. -type spendNotification struct { - targetOutpoint *wire.OutPoint - - spendChan chan *chainntnfs.SpendDetail - - spendID uint64 - - heightHint uint32 -} - -// spendCancel is a message sent to the NeutrinoNotifier when a client wishes -// to cancel an outstanding spend notification that has yet to be dispatched. -type spendCancel struct { - // op is the target outpoint of the notification to be cancelled. - op wire.OutPoint - - // spendID the ID of the notification to cancel. - spendID uint64 -} - // RegisterSpendNtfn registers an intent to be notified once the target // outpoint has been spent by a transaction on-chain. Once a spend of the // target outpoint has been detected, the details of the spending event will be