diff --git a/app/appmessage/rpc_notify_pruning_point_utxo_set_override.go b/app/appmessage/rpc_notify_pruning_point_utxo_set_override.go index 51244b6ea..de68e3eb6 100644 --- a/app/appmessage/rpc_notify_pruning_point_utxo_set_override.go +++ b/app/appmessage/rpc_notify_pruning_point_utxo_set_override.go @@ -54,6 +54,7 @@ func NewPruningPointUTXOSetOverrideNotificationMessage(id string) *PruningPointU // its respective RPC message type StopNotifyingPruningPointUTXOSetOverrideRequestMessage struct { baseMessage + Id string } // Command returns the protocol command string for the message @@ -63,7 +64,7 @@ func (msg *StopNotifyingPruningPointUTXOSetOverrideRequestMessage) Command() Mes // NewStopNotifyingPruningPointUTXOSetOverrideRequestMessage returns a instance of the message func NewStopNotifyingPruningPointUTXOSetOverrideRequestMessage(id string) *StopNotifyingPruningPointUTXOSetOverrideRequestMessage { - return &StopNotifyingPruningPointUTXOSetOverrideRequestMessage{} + return &StopNotifyingPruningPointUTXOSetOverrideRequestMessage{Id: id} } // StopNotifyingPruningPointUTXOSetOverrideResponseMessage is an appmessage corresponding to diff --git a/app/rpc/rpchandlers/notify_block_added.go b/app/rpc/rpchandlers/notify_block_added.go index d73dbfaaa..fd3113f68 100644 --- a/app/rpc/rpchandlers/notify_block_added.go +++ b/app/rpc/rpchandlers/notify_block_added.go @@ -8,15 +8,14 @@ import ( // HandleNotifyBlockAdded handles the respectively named RPC command func HandleNotifyBlockAdded(context *rpccontext.Context, router *router.Router, request appmessage.Message) (appmessage.Message, error) { + notifyBlockAddedRequestMessage := request.(*appmessage.NotifyBlockAddedRequestMessage) - notifyUTXOsChangedRequest := request.(*appmessage.NotifyUTXOsChangedRequestMessage) - listener, err := context.NotificationManager.Listener(router) if err != nil { return nil, err } - listener.PropagateBlockAddedNotifications() + listener.PropagateBlockAddedNotifications(notifyBlockAddedRequestMessage.Id) response := appmessage.NewNotifyBlockAddedResponseMessage(notifyBlockAddedRequestMessage.Id) return response, nil diff --git a/app/rpc/rpchandlers/notify_finality_conflicts.go b/app/rpc/rpchandlers/notify_finality_conflicts.go index a10de8c78..e7b35f2dd 100644 --- a/app/rpc/rpchandlers/notify_finality_conflicts.go +++ b/app/rpc/rpchandlers/notify_finality_conflicts.go @@ -9,15 +9,15 @@ import ( // HandleNotifyFinalityConflicts handles the respectively named RPC command func HandleNotifyFinalityConflicts(context *rpccontext.Context, router *router.Router, request appmessage.Message) (appmessage.Message, error) { - notifyUTXOsChangedRequest := request.(*appmessage.NotifyUTXOsChangedRequestMessage) + notifyFinalityConflictsRequest := request.(*appmessage.NotifyFinalityConflictsRequestMessage) listener, err := context.NotificationManager.Listener(router) if err != nil { return nil, err } - listener.PropagateFinalityConflictNotifications() - listener.PropagateFinalityConflictResolvedNotifications() + listener.PropagateFinalityConflictNotifications(notifyFinalityConflictsRequest.Id) + listener.PropagateFinalityConflictResolvedNotifications(notifyFinalityConflictsRequest.Id) - response := appmessage.NewNotifyFinalityConflictsResponseMessage() + response := appmessage.NewNotifyFinalityConflictsResponseMessage(notifyFinalityConflictsRequest.Id) return response, nil } diff --git a/app/rpc/rpchandlers/notify_new_block_template.go b/app/rpc/rpchandlers/notify_new_block_template.go index 176eaa006..b5bca7d93 100644 --- a/app/rpc/rpchandlers/notify_new_block_template.go +++ b/app/rpc/rpchandlers/notify_new_block_template.go @@ -9,14 +9,14 @@ import ( // HandleNotifyNewBlockTemplate handles the respectively named RPC command func HandleNotifyNewBlockTemplate(context *rpccontext.Context, router *router.Router, request appmessage.Message) (appmessage.Message, error) { - notifyUTXOsChangedRequest := request.(*appmessage.NotifyUTXOsChangedRequestMessage) + notifyNewBlockTemplateRequest := request.(*appmessage.NotifyNewBlockTemplateRequestMessage) listener, err := context.NotificationManager.Listener(router) if err != nil { return nil, err } - listener.PropagateNewBlockTemplateNotifications() + listener.PropagateNewBlockTemplateNotifications(notifyNewBlockTemplateRequest.Id) - response := appmessage.NewNotifyNewBlockTemplateResponseMessage() + response := appmessage.NewNotifyNewBlockTemplateResponseMessage(notifyNewBlockTemplateRequest.Id) return response, nil } diff --git a/app/rpc/rpchandlers/notify_pruning_point_utxo_set_overrides.go b/app/rpc/rpchandlers/notify_pruning_point_utxo_set_overrides.go index 4a913b4e4..c4278d0cf 100644 --- a/app/rpc/rpchandlers/notify_pruning_point_utxo_set_overrides.go +++ b/app/rpc/rpchandlers/notify_pruning_point_utxo_set_overrides.go @@ -9,14 +9,14 @@ import ( // HandleNotifyPruningPointUTXOSetOverrideRequest handles the respectively named RPC command func HandleNotifyPruningPointUTXOSetOverrideRequest(context *rpccontext.Context, router *router.Router, request appmessage.Message) (appmessage.Message, error) { - notifyUTXOsChangedRequest := request.(*appmessage.NotifyUTXOsChangedRequestMessage) + notifyPruningPointUTXOSetOverrideRequest := request.(*appmessage.NotifyPruningPointUTXOSetOverrideRequestMessage) listener, err := context.NotificationManager.Listener(router) if err != nil { return nil, err } - listener.PropagatePruningPointUTXOSetOverrideNotifications() + listener.PropagatePruningPointUTXOSetOverrideNotifications(notifyPruningPointUTXOSetOverrideRequest.Id) - response := appmessage.NewNotifyPruningPointUTXOSetOverrideResponseMessage() + response := appmessage.NewNotifyPruningPointUTXOSetOverrideResponseMessage(notifyPruningPointUTXOSetOverrideRequest.Id) return response, nil } diff --git a/app/rpc/rpchandlers/notify_utxos_changed.go b/app/rpc/rpchandlers/notify_utxos_changed.go index 41ffe0dd3..fab42b2a6 100644 --- a/app/rpc/rpchandlers/notify_utxos_changed.go +++ b/app/rpc/rpchandlers/notify_utxos_changed.go @@ -8,16 +8,18 @@ import ( // HandleNotifyUTXOsChanged handles the respectively named RPC command func HandleNotifyUTXOsChanged(context *rpccontext.Context, router *router.Router, request appmessage.Message) (appmessage.Message, error) { + + notifyUTXOsChangedRequest := request.(*appmessage.NotifyUTXOsChangedRequestMessage) + if !context.Config.UTXOIndex { - errorMessage := appmessage.NewNotifyUTXOsChangedResponseMessage() + errorMessage := appmessage.NewNotifyUTXOsChangedResponseMessage(notifyUTXOsChangedRequest.Id) errorMessage.Error = appmessage.RPCErrorf("Method unavailable when kaspad is run without --utxoindex") return errorMessage, nil } - notifyUTXOsChangedRequest := request.(*appmessage.NotifyUTXOsChangedRequestMessage) addresses, err := context.ConvertAddressStringsToUTXOsChangedNotificationAddresses(notifyUTXOsChangedRequest.Addresses) if err != nil { - errorMessage := appmessage.NewNotifyUTXOsChangedResponseMessage() + errorMessage := appmessage.NewNotifyUTXOsChangedResponseMessage(notifyUTXOsChangedRequest.Id) errorMessage.Error = appmessage.RPCErrorf("Parsing error: %s", err) return errorMessage, nil } @@ -26,8 +28,8 @@ func HandleNotifyUTXOsChanged(context *rpccontext.Context, router *router.Router if err != nil { return nil, err } - listener.PropagateUTXOsChangedNotifications(addresses) + listener.PropagateUTXOsChangedNotifications(addresses, notifyUTXOsChangedRequest.Id) - response := appmessage.NewNotifyUTXOsChangedResponseMessage() + response := appmessage.NewNotifyUTXOsChangedResponseMessage(notifyUTXOsChangedRequest.Id) return response, nil } diff --git a/app/rpc/rpchandlers/notify_virtual_daa_score_changed.go b/app/rpc/rpchandlers/notify_virtual_daa_score_changed.go index a9ddbc1f7..1798f5d1e 100644 --- a/app/rpc/rpchandlers/notify_virtual_daa_score_changed.go +++ b/app/rpc/rpchandlers/notify_virtual_daa_score_changed.go @@ -9,14 +9,14 @@ import ( // HandleNotifyVirtualDaaScoreChanged handles the respectively named RPC command func HandleNotifyVirtualDaaScoreChanged(context *rpccontext.Context, router *router.Router, request appmessage.Message) (appmessage.Message, error) { - notifyUTXOsChangedRequest := request.(*appmessage.NotifyUTXOsChangedRequestMessage) + notifyVirtualDaaScoreChangedRequest := request.(*appmessage.NotifyVirtualDaaScoreChangedRequestMessage) listener, err := context.NotificationManager.Listener(router) if err != nil { return nil, err } - listener.PropagateVirtualDaaScoreChangedNotifications() + listener.PropagateVirtualDaaScoreChangedNotifications(notifyVirtualDaaScoreChangedRequest.Id) - response := appmessage.NewNotifyVirtualDaaScoreChangedResponseMessage() + response := appmessage.NewNotifyVirtualDaaScoreChangedResponseMessage(notifyVirtualDaaScoreChangedRequest.Id) return response, nil } diff --git a/app/rpc/rpchandlers/notify_virtual_selected_parent_blue_score_changed.go b/app/rpc/rpchandlers/notify_virtual_selected_parent_blue_score_changed.go index 666f730f1..ecbfb48c4 100644 --- a/app/rpc/rpchandlers/notify_virtual_selected_parent_blue_score_changed.go +++ b/app/rpc/rpchandlers/notify_virtual_selected_parent_blue_score_changed.go @@ -9,14 +9,14 @@ import ( // HandleNotifyVirtualSelectedParentBlueScoreChanged handles the respectively named RPC command func HandleNotifyVirtualSelectedParentBlueScoreChanged(context *rpccontext.Context, router *router.Router, request appmessage.Message) (appmessage.Message, error) { - notifyUTXOsChangedRequest := request.(*appmessage.NotifyUTXOsChangedRequestMessage) + notifyVirtualSelectedParentBlueScoreChangedRequest := request.(*appmessage.NotifyVirtualSelectedParentBlueScoreChangedRequestMessage) listener, err := context.NotificationManager.Listener(router) if err != nil { return nil, err } - listener.PropagateVirtualSelectedParentBlueScoreChangedNotifications() + listener.PropagateVirtualSelectedParentBlueScoreChangedNotifications(notifyVirtualSelectedParentBlueScoreChangedRequest.Id) - response := appmessage.NewNotifyVirtualSelectedParentBlueScoreChangedResponseMessage() + response := appmessage.NewNotifyVirtualSelectedParentBlueScoreChangedResponseMessage(notifyVirtualSelectedParentBlueScoreChangedRequest.Id) return response, nil } diff --git a/app/rpc/rpchandlers/notify_virtual_selected_parent_chain_changed.go b/app/rpc/rpchandlers/notify_virtual_selected_parent_chain_changed.go index 90119a5fb..b9a019b23 100644 --- a/app/rpc/rpchandlers/notify_virtual_selected_parent_chain_changed.go +++ b/app/rpc/rpchandlers/notify_virtual_selected_parent_chain_changed.go @@ -17,8 +17,9 @@ func HandleNotifyVirtualSelectedParentChainChanged(context *rpccontext.Context, return nil, err } listener.PropagateVirtualSelectedParentChainChangedNotifications( - notifyVirtualSelectedParentChainChangedRequest.IncludeAcceptedTransactionIDs) + notifyVirtualSelectedParentChainChangedRequest.IncludeAcceptedTransactionIDs, + notifyVirtualSelectedParentChainChangedRequest.Id) - response := appmessage.NewNotifyVirtualSelectedParentChainChangedResponseMessage() + response := appmessage.NewNotifyVirtualSelectedParentChainChangedResponseMessage(notifyVirtualSelectedParentChainChangedRequest.Id) return response, nil } diff --git a/app/rpc/rpchandlers/stop_notifying_pruning_point_utxo_set_overrides.go b/app/rpc/rpchandlers/stop_notifying_pruning_point_utxo_set_overrides.go index 8c865bf5b..932cd7bd1 100644 --- a/app/rpc/rpchandlers/stop_notifying_pruning_point_utxo_set_overrides.go +++ b/app/rpc/rpchandlers/stop_notifying_pruning_point_utxo_set_overrides.go @@ -9,14 +9,14 @@ import ( // HandleStopNotifyingPruningPointUTXOSetOverrideRequest handles the respectively named RPC command func HandleStopNotifyingPruningPointUTXOSetOverrideRequest(context *rpccontext.Context, router *router.Router, request appmessage.Message) (appmessage.Message, error) { - notifyUTXOsChangedRequest := request.(*appmessage.NotifyUTXOsChangedRequestMessage) + stopNotifyingPruningPointUTXOSetOverrideRequest := request.(*appmessage.StopNotifyingPruningPointUTXOSetOverrideRequestMessage) listener, err := context.NotificationManager.Listener(router) if err != nil { return nil, err } - listener.StopPropagatingPruningPointUTXOSetOverrideNotifications() + listener.StopPropagatingPruningPointUTXOSetOverrideNotifications(stopNotifyingPruningPointUTXOSetOverrideRequest.Id) - response := appmessage.NewStopNotifyingPruningPointUTXOSetOverrideResponseMessage() + response := appmessage.NewStopNotifyingPruningPointUTXOSetOverrideResponseMessage(stopNotifyingPruningPointUTXOSetOverrideRequest.Id) return response, nil } diff --git a/app/rpc/rpchandlers/stop_notifying_utxos_changed.go b/app/rpc/rpchandlers/stop_notifying_utxos_changed.go index 0da89a9bf..f4b5d4d5f 100644 --- a/app/rpc/rpchandlers/stop_notifying_utxos_changed.go +++ b/app/rpc/rpchandlers/stop_notifying_utxos_changed.go @@ -8,16 +8,18 @@ import ( // HandleStopNotifyingUTXOsChanged handles the respectively named RPC command func HandleStopNotifyingUTXOsChanged(context *rpccontext.Context, router *router.Router, request appmessage.Message) (appmessage.Message, error) { + + stopNotifyingUTXOsChangedRequest := request.(*appmessage.StopNotifyingUTXOsChangedRequestMessage) + if !context.Config.UTXOIndex { - errorMessage := appmessage.NewStopNotifyingUTXOsChangedResponseMessage() + errorMessage := appmessage.NewStopNotifyingUTXOsChangedResponseMessage(stopNotifyingUTXOsChangedRequest.Id) errorMessage.Error = appmessage.RPCErrorf("Method unavailable when kaspad is run without --utxoindex") return errorMessage, nil } - stopNotifyingUTXOsChangedRequest := request.(*appmessage.StopNotifyingUTXOsChangedRequestMessage) addresses, err := context.ConvertAddressStringsToUTXOsChangedNotificationAddresses(stopNotifyingUTXOsChangedRequest.Addresses) if err != nil { - errorMessage := appmessage.NewNotifyUTXOsChangedResponseMessage() + errorMessage := appmessage.NewNotifyUTXOsChangedResponseMessage(stopNotifyingUTXOsChangedRequest.Id) errorMessage.Error = appmessage.RPCErrorf("Parsing error: %s", err) return errorMessage, nil } @@ -28,6 +30,6 @@ func HandleStopNotifyingUTXOsChanged(context *rpccontext.Context, router *router } listener.StopPropagatingUTXOsChangedNotifications(addresses) - response := appmessage.NewStopNotifyingUTXOsChangedResponseMessage() + response := appmessage.NewStopNotifyingUTXOsChangedResponseMessage(stopNotifyingUTXOsChangedRequest.Id) return response, nil }