From 830f3c45894da24ac4eb5f0416ad9b563ed5d79e Mon Sep 17 00:00:00 2001 From: D-Stacks Date: Fri, 17 Jun 2022 11:56:56 +0200 Subject: [PATCH] add id in converter --- app/rpc/rpccontext/notificationmanager.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/rpc/rpccontext/notificationmanager.go b/app/rpc/rpccontext/notificationmanager.go index ccfda5fe3..7aa620052 100644 --- a/app/rpc/rpccontext/notificationmanager.go +++ b/app/rpc/rpccontext/notificationmanager.go @@ -217,13 +217,11 @@ func (nm *NotificationManager) NotifyUTXOsChanged(utxoChanges *utxoindex.UTXOCha for router, listener := range nm.listeners { if listener.propagateUTXOsChangedNotifications { // Filter utxoChanges and create a notification - notification, err := listener.convertUTXOChangesToUTXOsChangedNotification(utxoChanges) + notification, err := listener.convertUTXOChangesToUTXOsChangedNotification(utxoChanges, listener.propagateUTXOsChangedNotificationsID) if err != nil { return err } - notification.ID = listener.propagateUTXOsChangedNotificationsID - // Don't send the notification if it's empty if len(notification.Added) == 0 && len(notification.Removed) == 0 { continue @@ -403,7 +401,7 @@ func (nl *NotificationListener) StopPropagatingUTXOsChangedNotifications(address } func (nl *NotificationListener) convertUTXOChangesToUTXOsChangedNotification( - utxoChanges *utxoindex.UTXOChanges) (*appmessage.UTXOsChangedNotificationMessage, error) { + utxoChanges *utxoindex.UTXOChanges, id string) (*appmessage.UTXOsChangedNotificationMessage, error) { // As an optimization, we iterate over the smaller set (O(n)) among the two below // and check existence over the larger set (O(1)) @@ -411,6 +409,9 @@ func (nl *NotificationListener) convertUTXOChangesToUTXOsChangedNotification( addressesSize := len(nl.propagateUTXOsChangedNotificationAddresses) notification := &appmessage.UTXOsChangedNotificationMessage{} + + notification.ID = id + if utxoChangesSize < addressesSize { for scriptPublicKeyString, addedPairs := range utxoChanges.Added { if listenerAddress, ok := nl.propagateUTXOsChangedNotificationAddresses[scriptPublicKeyString]; ok {