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.
This commit is contained in:
parent
bfd11a251e
commit
deca4cfe44
@ -68,8 +68,6 @@ type NeutrinoNotifier struct {
|
|||||||
notificationCancels chan interface{}
|
notificationCancels chan interface{}
|
||||||
notificationRegistry chan interface{}
|
notificationRegistry chan interface{}
|
||||||
|
|
||||||
spendNotifications map[wire.OutPoint]map[uint64]*spendNotification
|
|
||||||
|
|
||||||
txNotifier *chainntnfs.TxNotifier
|
txNotifier *chainntnfs.TxNotifier
|
||||||
|
|
||||||
blockEpochClients map[uint64]*blockEpochRegistration
|
blockEpochClients map[uint64]*blockEpochRegistration
|
||||||
@ -109,8 +107,6 @@ func New(node *neutrino.ChainService, spendHintCache chainntnfs.SpendHintCache,
|
|||||||
|
|
||||||
blockEpochClients: make(map[uint64]*blockEpochRegistration),
|
blockEpochClients: make(map[uint64]*blockEpochRegistration),
|
||||||
|
|
||||||
spendNotifications: make(map[wire.OutPoint]map[uint64]*spendNotification),
|
|
||||||
|
|
||||||
p2pNode: node,
|
p2pNode: node,
|
||||||
|
|
||||||
rescanErr: make(chan error),
|
rescanErr: make(chan error),
|
||||||
@ -196,11 +192,6 @@ func (n *NeutrinoNotifier) Stop() error {
|
|||||||
|
|
||||||
// Notify all pending clients of our shutdown by closing the related
|
// Notify all pending clients of our shutdown by closing the related
|
||||||
// notification channels.
|
// notification channels.
|
||||||
for _, spendClients := range n.spendNotifications {
|
|
||||||
for _, spendClient := range spendClients {
|
|
||||||
close(spendClient.spendChan)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for _, epochClient := range n.blockEpochClients {
|
for _, epochClient := range n.blockEpochClients {
|
||||||
close(epochClient.cancelChan)
|
close(epochClient.cancelChan)
|
||||||
epochClient.wg.Wait()
|
epochClient.wg.Wait()
|
||||||
@ -264,19 +255,6 @@ out:
|
|||||||
select {
|
select {
|
||||||
case cancelMsg := <-n.notificationCancels:
|
case cancelMsg := <-n.notificationCancels:
|
||||||
switch msg := cancelMsg.(type) {
|
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:
|
case *epochCancel:
|
||||||
chainntnfs.Log.Infof("Cancelling epoch "+
|
chainntnfs.Log.Infof("Cancelling epoch "+
|
||||||
"notification, epoch_id=%v", msg.epochID)
|
"notification, epoch_id=%v", msg.epochID)
|
||||||
@ -304,17 +282,6 @@ out:
|
|||||||
|
|
||||||
case registerMsg := <-n.notificationRegistry:
|
case registerMsg := <-n.notificationRegistry:
|
||||||
switch msg := registerMsg.(type) {
|
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:
|
case *chainntnfs.HistoricalConfDispatch:
|
||||||
// Look up whether the transaction is already
|
// Look up whether the transaction is already
|
||||||
// included in the active chain. We'll do this
|
// 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
|
// RegisterSpendNtfn registers an intent to be notified once the target
|
||||||
// outpoint has been spent by a transaction on-chain. Once a spend of the
|
// 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
|
// target outpoint has been detected, the details of the spending event will be
|
||||||
|
Loading…
Reference in New Issue
Block a user