chainntnfs: remove subscriptions when the relevant tx is confirmed
This commit removes the subscribed inputs from mempool notifier when the relevant transaction is confirmed.
This commit is contained in:
4 files changed
+146
-28
No files matched your search
@@ -140,6 +140,23 @@ func (m *MempoolNotifier) UnsubscribeEvent(sub *MempoolSpendEvent) {
|
||||
clients.Delete(sub.id)
|
||||
}
|
||||
|
||||
// UnsubsribeConfirmedSpentTx takes a transaction and removes the subscriptions
|
||||
// identified using its inputs.
|
||||
func (m *MempoolNotifier) UnsubsribeConfirmedSpentTx(tx *btcutil.Tx) {
|
||||
Log.Tracef("Unsubscribe confirmed tx %s", tx.Hash())
|
||||
|
||||
// Get the spent inputs of interest.
|
||||
spentInputs := m.findRelevantInputs(tx)
|
||||
|
||||
// Unsubscribe the subscribers.
|
||||
for outpoint := range spentInputs {
|
||||
m.UnsubscribeInput(outpoint)
|
||||
}
|
||||
|
||||
Log.Tracef("Finished unsubscribing confirmed tx %s, found %d inputs",
|
||||
tx.Hash(), len(spentInputs))
|
||||
}
|
||||
|
||||
// ProcessRelevantSpendTx takes a transaction and checks whether it spends any
|
||||
// of the subscribed inputs. If so, spend notifications are sent to the
|
||||
// relevant subscribers.
|
||||
|
||||
Reference in new issue
Block a user