chainntnfs/btcdnotify: remove old spend notification handling logic
In this commit, we remove the old spend notification logic within the BtcdNotifier as it's been phased out by the TxNotifier.
This commit is contained in:
parent
88edd320d5
commit
74139c9a3f
@ -74,8 +74,6 @@ type BtcdNotifier struct {
|
||||
notificationCancels chan interface{}
|
||||
notificationRegistry chan interface{}
|
||||
|
||||
spendNotifications map[wire.OutPoint]map[uint64]*spendNotification
|
||||
|
||||
txNotifier *chainntnfs.TxNotifier
|
||||
|
||||
blockEpochClients map[uint64]*blockEpochRegistration
|
||||
@ -114,8 +112,6 @@ func New(config *rpcclient.ConnConfig, spendHintCache chainntnfs.SpendHintCache,
|
||||
|
||||
blockEpochClients: make(map[uint64]*blockEpochRegistration),
|
||||
|
||||
spendNotifications: make(map[wire.OutPoint]map[uint64]*spendNotification),
|
||||
|
||||
chainUpdates: queue.NewConcurrentQueue(10),
|
||||
txUpdates: queue.NewConcurrentQueue(10),
|
||||
|
||||
@ -204,11 +200,6 @@ func (b *BtcdNotifier) Stop() error {
|
||||
|
||||
// Notify all pending clients of our shutdown by closing the related
|
||||
// notification channels.
|
||||
for _, spendClients := range b.spendNotifications {
|
||||
for _, spendClient := range spendClients {
|
||||
close(spendClient.spendChan)
|
||||
}
|
||||
}
|
||||
for _, epochClient := range b.blockEpochClients {
|
||||
close(epochClient.cancelChan)
|
||||
epochClient.wg.Wait()
|
||||
@ -276,19 +267,6 @@ out:
|
||||
select {
|
||||
case cancelMsg := <-b.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 := b.spendNotifications[msg.op]; ok {
|
||||
close(outPointClients[msg.spendID].spendChan)
|
||||
delete(b.spendNotifications[msg.op], msg.spendID)
|
||||
}
|
||||
|
||||
case *epochCancel:
|
||||
chainntnfs.Log.Infof("Cancelling epoch "+
|
||||
"notification, epoch_id=%v", msg.epochID)
|
||||
@ -315,16 +293,6 @@ out:
|
||||
}
|
||||
case registerMsg := <-b.notificationRegistry:
|
||||
switch msg := registerMsg.(type) {
|
||||
case *spendNotification:
|
||||
chainntnfs.Log.Infof("New spend subscription: "+
|
||||
"utxo=%v", msg.targetOutpoint)
|
||||
op := *msg.targetOutpoint
|
||||
|
||||
if _, ok := b.spendNotifications[op]; !ok {
|
||||
b.spendNotifications[op] = make(map[uint64]*spendNotification)
|
||||
}
|
||||
b.spendNotifications[op][msg.spendID] = msg
|
||||
|
||||
case *chainntnfs.HistoricalConfDispatch:
|
||||
// Look up whether the transaction is already
|
||||
// included in the active chain. We'll do this
|
||||
@ -713,28 +681,6 @@ func (b *BtcdNotifier) notifyBlockEpochClient(epochClient *blockEpochRegistratio
|
||||
}
|
||||
}
|
||||
|
||||
// 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 BtcdNotifier 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 sent
|
||||
|
Loading…
Reference in New Issue
Block a user