Merge 93d9a753628cf6a9c776e16112096640622bca97 into 9ee409afaa6955b67e8c464af94c46aea9b77179

This commit is contained in:
D-Stacks 2022-08-16 10:47:27 +03:00 committed by GitHub
commit 3cbcc08a96
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
46 changed files with 1868 additions and 665 deletions

View File

@ -3,6 +3,7 @@ package appmessage
// NotifyBlockAddedRequestMessage is an appmessage corresponding to // NotifyBlockAddedRequestMessage is an appmessage corresponding to
// its respective RPC message // its respective RPC message
type NotifyBlockAddedRequestMessage struct { type NotifyBlockAddedRequestMessage struct {
ID string
baseMessage baseMessage
} }
@ -12,14 +13,15 @@ func (msg *NotifyBlockAddedRequestMessage) Command() MessageCommand {
} }
// NewNotifyBlockAddedRequestMessage returns a instance of the message // NewNotifyBlockAddedRequestMessage returns a instance of the message
func NewNotifyBlockAddedRequestMessage() *NotifyBlockAddedRequestMessage { func NewNotifyBlockAddedRequestMessage(id string) *NotifyBlockAddedRequestMessage {
return &NotifyBlockAddedRequestMessage{} return &NotifyBlockAddedRequestMessage{ID: id}
} }
// NotifyBlockAddedResponseMessage is an appmessage corresponding to // NotifyBlockAddedResponseMessage is an appmessage corresponding to
// its respective RPC message // its respective RPC message
type NotifyBlockAddedResponseMessage struct { type NotifyBlockAddedResponseMessage struct {
baseMessage baseMessage
ID string
Error *RPCError Error *RPCError
} }
@ -29,14 +31,15 @@ func (msg *NotifyBlockAddedResponseMessage) Command() MessageCommand {
} }
// NewNotifyBlockAddedResponseMessage returns a instance of the message // NewNotifyBlockAddedResponseMessage returns a instance of the message
func NewNotifyBlockAddedResponseMessage() *NotifyBlockAddedResponseMessage { func NewNotifyBlockAddedResponseMessage(id string) *NotifyBlockAddedResponseMessage {
return &NotifyBlockAddedResponseMessage{} return &NotifyBlockAddedResponseMessage{ID: id}
} }
// BlockAddedNotificationMessage is an appmessage corresponding to // BlockAddedNotificationMessage is an appmessage corresponding to
// its respective RPC message // its respective RPC message
type BlockAddedNotificationMessage struct { type BlockAddedNotificationMessage struct {
baseMessage baseMessage
ID string
Block *RPCBlock Block *RPCBlock
} }
@ -46,8 +49,9 @@ func (msg *BlockAddedNotificationMessage) Command() MessageCommand {
} }
// NewBlockAddedNotificationMessage returns a instance of the message // NewBlockAddedNotificationMessage returns a instance of the message
func NewBlockAddedNotificationMessage(block *RPCBlock) *BlockAddedNotificationMessage { func NewBlockAddedNotificationMessage(block *RPCBlock, id string) *BlockAddedNotificationMessage {
return &BlockAddedNotificationMessage{ return &BlockAddedNotificationMessage{
ID: id,
Block: block, Block: block,
} }
} }

View File

@ -4,6 +4,7 @@ package appmessage
// its respective RPC message // its respective RPC message
type NotifyFinalityConflictsRequestMessage struct { type NotifyFinalityConflictsRequestMessage struct {
baseMessage baseMessage
ID string
} }
// Command returns the protocol command string for the message // Command returns the protocol command string for the message
@ -12,14 +13,15 @@ func (msg *NotifyFinalityConflictsRequestMessage) Command() MessageCommand {
} }
// NewNotifyFinalityConflictsRequestMessage returns a instance of the message // NewNotifyFinalityConflictsRequestMessage returns a instance of the message
func NewNotifyFinalityConflictsRequestMessage() *NotifyFinalityConflictsRequestMessage { func NewNotifyFinalityConflictsRequestMessage(id string) *NotifyFinalityConflictsRequestMessage {
return &NotifyFinalityConflictsRequestMessage{} return &NotifyFinalityConflictsRequestMessage{ID: id}
} }
// NotifyFinalityConflictsResponseMessage is an appmessage corresponding to // NotifyFinalityConflictsResponseMessage is an appmessage corresponding to
// its respective RPC message // its respective RPC message
type NotifyFinalityConflictsResponseMessage struct { type NotifyFinalityConflictsResponseMessage struct {
baseMessage baseMessage
ID string
Error *RPCError Error *RPCError
} }
@ -29,14 +31,15 @@ func (msg *NotifyFinalityConflictsResponseMessage) Command() MessageCommand {
} }
// NewNotifyFinalityConflictsResponseMessage returns a instance of the message // NewNotifyFinalityConflictsResponseMessage returns a instance of the message
func NewNotifyFinalityConflictsResponseMessage() *NotifyFinalityConflictsResponseMessage { func NewNotifyFinalityConflictsResponseMessage(id string) *NotifyFinalityConflictsResponseMessage {
return &NotifyFinalityConflictsResponseMessage{} return &NotifyFinalityConflictsResponseMessage{ID: id}
} }
// FinalityConflictNotificationMessage is an appmessage corresponding to // FinalityConflictNotificationMessage is an appmessage corresponding to
// its respective RPC message // its respective RPC message
type FinalityConflictNotificationMessage struct { type FinalityConflictNotificationMessage struct {
baseMessage baseMessage
ID string
ViolatingBlockHash string ViolatingBlockHash string
} }
@ -46,8 +49,9 @@ func (msg *FinalityConflictNotificationMessage) Command() MessageCommand {
} }
// NewFinalityConflictNotificationMessage returns a instance of the message // NewFinalityConflictNotificationMessage returns a instance of the message
func NewFinalityConflictNotificationMessage(violatingBlockHash string) *FinalityConflictNotificationMessage { func NewFinalityConflictNotificationMessage(violatingBlockHash string, id string) *FinalityConflictNotificationMessage {
return &FinalityConflictNotificationMessage{ return &FinalityConflictNotificationMessage{
ID: id,
ViolatingBlockHash: violatingBlockHash, ViolatingBlockHash: violatingBlockHash,
} }
} }
@ -56,6 +60,7 @@ func NewFinalityConflictNotificationMessage(violatingBlockHash string) *Finality
// its respective RPC message // its respective RPC message
type FinalityConflictResolvedNotificationMessage struct { type FinalityConflictResolvedNotificationMessage struct {
baseMessage baseMessage
ID string
FinalityBlockHash string FinalityBlockHash string
} }
@ -65,8 +70,9 @@ func (msg *FinalityConflictResolvedNotificationMessage) Command() MessageCommand
} }
// NewFinalityConflictResolvedNotificationMessage returns a instance of the message // NewFinalityConflictResolvedNotificationMessage returns a instance of the message
func NewFinalityConflictResolvedNotificationMessage(finalityBlockHash string) *FinalityConflictResolvedNotificationMessage { func NewFinalityConflictResolvedNotificationMessage(finalityBlockHash string, id string) *FinalityConflictResolvedNotificationMessage {
return &FinalityConflictResolvedNotificationMessage{ return &FinalityConflictResolvedNotificationMessage{
ID: id,
FinalityBlockHash: finalityBlockHash, FinalityBlockHash: finalityBlockHash,
} }
} }

View File

@ -4,6 +4,7 @@ package appmessage
// its respective RPC message // its respective RPC message
type NotifyNewBlockTemplateRequestMessage struct { type NotifyNewBlockTemplateRequestMessage struct {
baseMessage baseMessage
ID string
} }
// Command returns the protocol command string for the message // Command returns the protocol command string for the message
@ -12,14 +13,15 @@ func (msg *NotifyNewBlockTemplateRequestMessage) Command() MessageCommand {
} }
// NewNotifyNewBlockTemplateRequestMessage returns an instance of the message // NewNotifyNewBlockTemplateRequestMessage returns an instance of the message
func NewNotifyNewBlockTemplateRequestMessage() *NotifyNewBlockTemplateRequestMessage { func NewNotifyNewBlockTemplateRequestMessage(id string) *NotifyNewBlockTemplateRequestMessage {
return &NotifyNewBlockTemplateRequestMessage{} return &NotifyNewBlockTemplateRequestMessage{ID: id}
} }
// NotifyNewBlockTemplateResponseMessage is an appmessage corresponding to // NotifyNewBlockTemplateResponseMessage is an appmessage corresponding to
// its respective RPC message // its respective RPC message
type NotifyNewBlockTemplateResponseMessage struct { type NotifyNewBlockTemplateResponseMessage struct {
baseMessage baseMessage
ID string
Error *RPCError Error *RPCError
} }
@ -29,14 +31,15 @@ func (msg *NotifyNewBlockTemplateResponseMessage) Command() MessageCommand {
} }
// NewNotifyNewBlockTemplateResponseMessage returns an instance of the message // NewNotifyNewBlockTemplateResponseMessage returns an instance of the message
func NewNotifyNewBlockTemplateResponseMessage() *NotifyNewBlockTemplateResponseMessage { func NewNotifyNewBlockTemplateResponseMessage(id string) *NotifyNewBlockTemplateResponseMessage {
return &NotifyNewBlockTemplateResponseMessage{} return &NotifyNewBlockTemplateResponseMessage{ID: id}
} }
// NewBlockTemplateNotificationMessage is an appmessage corresponding to // NewBlockTemplateNotificationMessage is an appmessage corresponding to
// its respective RPC message // its respective RPC message
type NewBlockTemplateNotificationMessage struct { type NewBlockTemplateNotificationMessage struct {
baseMessage baseMessage
ID string
} }
// Command returns the protocol command string for the message // Command returns the protocol command string for the message
@ -45,6 +48,6 @@ func (msg *NewBlockTemplateNotificationMessage) Command() MessageCommand {
} }
// NewNewBlockTemplateNotificationMessage returns an instance of the message // NewNewBlockTemplateNotificationMessage returns an instance of the message
func NewNewBlockTemplateNotificationMessage() *NewBlockTemplateNotificationMessage { func NewNewBlockTemplateNotificationMessage(id string) *NewBlockTemplateNotificationMessage {
return &NewBlockTemplateNotificationMessage{} return &NewBlockTemplateNotificationMessage{ID: id}
} }

View File

@ -4,6 +4,7 @@ package appmessage
// its respective RPC message // its respective RPC message
type NotifyPruningPointUTXOSetOverrideRequestMessage struct { type NotifyPruningPointUTXOSetOverrideRequestMessage struct {
baseMessage baseMessage
ID string
} }
// Command returns the protocol command string for the message // Command returns the protocol command string for the message
@ -12,14 +13,15 @@ func (msg *NotifyPruningPointUTXOSetOverrideRequestMessage) Command() MessageCom
} }
// NewNotifyPruningPointUTXOSetOverrideRequestMessage returns a instance of the message // NewNotifyPruningPointUTXOSetOverrideRequestMessage returns a instance of the message
func NewNotifyPruningPointUTXOSetOverrideRequestMessage() *NotifyPruningPointUTXOSetOverrideRequestMessage { func NewNotifyPruningPointUTXOSetOverrideRequestMessage(id string) *NotifyPruningPointUTXOSetOverrideRequestMessage {
return &NotifyPruningPointUTXOSetOverrideRequestMessage{} return &NotifyPruningPointUTXOSetOverrideRequestMessage{ID: id}
} }
// NotifyPruningPointUTXOSetOverrideResponseMessage is an appmessage corresponding to // NotifyPruningPointUTXOSetOverrideResponseMessage is an appmessage corresponding to
// its respective RPC message // its respective RPC message
type NotifyPruningPointUTXOSetOverrideResponseMessage struct { type NotifyPruningPointUTXOSetOverrideResponseMessage struct {
baseMessage baseMessage
ID string
Error *RPCError Error *RPCError
} }
@ -29,14 +31,15 @@ func (msg *NotifyPruningPointUTXOSetOverrideResponseMessage) Command() MessageCo
} }
// NewNotifyPruningPointUTXOSetOverrideResponseMessage returns a instance of the message // NewNotifyPruningPointUTXOSetOverrideResponseMessage returns a instance of the message
func NewNotifyPruningPointUTXOSetOverrideResponseMessage() *NotifyPruningPointUTXOSetOverrideResponseMessage { func NewNotifyPruningPointUTXOSetOverrideResponseMessage(id string) *NotifyPruningPointUTXOSetOverrideResponseMessage {
return &NotifyPruningPointUTXOSetOverrideResponseMessage{} return &NotifyPruningPointUTXOSetOverrideResponseMessage{ID: id}
} }
// PruningPointUTXOSetOverrideNotificationMessage is an appmessage corresponding to // PruningPointUTXOSetOverrideNotificationMessage is an appmessage corresponding to
// its respective RPC message // its respective RPC message
type PruningPointUTXOSetOverrideNotificationMessage struct { type PruningPointUTXOSetOverrideNotificationMessage struct {
baseMessage baseMessage
ID string
} }
// Command returns the protocol command string for the message // Command returns the protocol command string for the message
@ -45,14 +48,15 @@ func (msg *PruningPointUTXOSetOverrideNotificationMessage) Command() MessageComm
} }
// NewPruningPointUTXOSetOverrideNotificationMessage returns a instance of the message // NewPruningPointUTXOSetOverrideNotificationMessage returns a instance of the message
func NewPruningPointUTXOSetOverrideNotificationMessage() *PruningPointUTXOSetOverrideNotificationMessage { func NewPruningPointUTXOSetOverrideNotificationMessage(id string) *PruningPointUTXOSetOverrideNotificationMessage {
return &PruningPointUTXOSetOverrideNotificationMessage{} return &PruningPointUTXOSetOverrideNotificationMessage{ID: id}
} }
// StopNotifyingPruningPointUTXOSetOverrideRequestMessage is an appmessage corresponding to // StopNotifyingPruningPointUTXOSetOverrideRequestMessage is an appmessage corresponding to
// its respective RPC message // its respective RPC message
type StopNotifyingPruningPointUTXOSetOverrideRequestMessage struct { type StopNotifyingPruningPointUTXOSetOverrideRequestMessage struct {
baseMessage baseMessage
ID string
} }
// Command returns the protocol command string for the message // Command returns the protocol command string for the message
@ -61,14 +65,15 @@ func (msg *StopNotifyingPruningPointUTXOSetOverrideRequestMessage) Command() Mes
} }
// NewStopNotifyingPruningPointUTXOSetOverrideRequestMessage returns a instance of the message // NewStopNotifyingPruningPointUTXOSetOverrideRequestMessage returns a instance of the message
func NewStopNotifyingPruningPointUTXOSetOverrideRequestMessage() *StopNotifyingPruningPointUTXOSetOverrideRequestMessage { func NewStopNotifyingPruningPointUTXOSetOverrideRequestMessage(id string) *StopNotifyingPruningPointUTXOSetOverrideRequestMessage {
return &StopNotifyingPruningPointUTXOSetOverrideRequestMessage{} return &StopNotifyingPruningPointUTXOSetOverrideRequestMessage{ID: id}
} }
// StopNotifyingPruningPointUTXOSetOverrideResponseMessage is an appmessage corresponding to // StopNotifyingPruningPointUTXOSetOverrideResponseMessage is an appmessage corresponding to
// its respective RPC message // its respective RPC message
type StopNotifyingPruningPointUTXOSetOverrideResponseMessage struct { type StopNotifyingPruningPointUTXOSetOverrideResponseMessage struct {
baseMessage baseMessage
ID string
Error *RPCError Error *RPCError
} }
@ -78,6 +83,6 @@ func (msg *StopNotifyingPruningPointUTXOSetOverrideResponseMessage) Command() Me
} }
// NewStopNotifyingPruningPointUTXOSetOverrideResponseMessage returns a instance of the message // NewStopNotifyingPruningPointUTXOSetOverrideResponseMessage returns a instance of the message
func NewStopNotifyingPruningPointUTXOSetOverrideResponseMessage() *StopNotifyingPruningPointUTXOSetOverrideResponseMessage { func NewStopNotifyingPruningPointUTXOSetOverrideResponseMessage(id string) *StopNotifyingPruningPointUTXOSetOverrideResponseMessage {
return &StopNotifyingPruningPointUTXOSetOverrideResponseMessage{} return &StopNotifyingPruningPointUTXOSetOverrideResponseMessage{ID: id}
} }

View File

@ -4,6 +4,7 @@ package appmessage
// its respective RPC message // its respective RPC message
type NotifyUTXOsChangedRequestMessage struct { type NotifyUTXOsChangedRequestMessage struct {
baseMessage baseMessage
ID string
Addresses []string Addresses []string
} }
@ -13,8 +14,9 @@ func (msg *NotifyUTXOsChangedRequestMessage) Command() MessageCommand {
} }
// NewNotifyUTXOsChangedRequestMessage returns a instance of the message // NewNotifyUTXOsChangedRequestMessage returns a instance of the message
func NewNotifyUTXOsChangedRequestMessage(addresses []string) *NotifyUTXOsChangedRequestMessage { func NewNotifyUTXOsChangedRequestMessage(addresses []string, id string) *NotifyUTXOsChangedRequestMessage {
return &NotifyUTXOsChangedRequestMessage{ return &NotifyUTXOsChangedRequestMessage{
ID: id,
Addresses: addresses, Addresses: addresses,
} }
} }
@ -23,6 +25,7 @@ func NewNotifyUTXOsChangedRequestMessage(addresses []string) *NotifyUTXOsChanged
// its respective RPC message // its respective RPC message
type NotifyUTXOsChangedResponseMessage struct { type NotifyUTXOsChangedResponseMessage struct {
baseMessage baseMessage
ID string
Error *RPCError Error *RPCError
} }
@ -32,14 +35,15 @@ func (msg *NotifyUTXOsChangedResponseMessage) Command() MessageCommand {
} }
// NewNotifyUTXOsChangedResponseMessage returns a instance of the message // NewNotifyUTXOsChangedResponseMessage returns a instance of the message
func NewNotifyUTXOsChangedResponseMessage() *NotifyUTXOsChangedResponseMessage { func NewNotifyUTXOsChangedResponseMessage(id string) *NotifyUTXOsChangedResponseMessage {
return &NotifyUTXOsChangedResponseMessage{} return &NotifyUTXOsChangedResponseMessage{ID: id}
} }
// UTXOsChangedNotificationMessage is an appmessage corresponding to // UTXOsChangedNotificationMessage is an appmessage corresponding to
// its respective RPC message // its respective RPC message
type UTXOsChangedNotificationMessage struct { type UTXOsChangedNotificationMessage struct {
baseMessage baseMessage
ID string
Added []*UTXOsByAddressesEntry Added []*UTXOsByAddressesEntry
Removed []*UTXOsByAddressesEntry Removed []*UTXOsByAddressesEntry
} }
@ -57,6 +61,6 @@ func (msg *UTXOsChangedNotificationMessage) Command() MessageCommand {
} }
// NewUTXOsChangedNotificationMessage returns a instance of the message // NewUTXOsChangedNotificationMessage returns a instance of the message
func NewUTXOsChangedNotificationMessage() *UTXOsChangedNotificationMessage { func NewUTXOsChangedNotificationMessage(id string) *UTXOsChangedNotificationMessage {
return &UTXOsChangedNotificationMessage{} return &UTXOsChangedNotificationMessage{ID: id}
} }

View File

@ -4,6 +4,7 @@ package appmessage
// its respective RPC message // its respective RPC message
type NotifyVirtualDaaScoreChangedRequestMessage struct { type NotifyVirtualDaaScoreChangedRequestMessage struct {
baseMessage baseMessage
ID string
} }
// Command returns the protocol command string for the message // Command returns the protocol command string for the message
@ -12,14 +13,15 @@ func (msg *NotifyVirtualDaaScoreChangedRequestMessage) Command() MessageCommand
} }
// NewNotifyVirtualDaaScoreChangedRequestMessage returns a instance of the message // NewNotifyVirtualDaaScoreChangedRequestMessage returns a instance of the message
func NewNotifyVirtualDaaScoreChangedRequestMessage() *NotifyVirtualDaaScoreChangedRequestMessage { func NewNotifyVirtualDaaScoreChangedRequestMessage(id string) *NotifyVirtualDaaScoreChangedRequestMessage {
return &NotifyVirtualDaaScoreChangedRequestMessage{} return &NotifyVirtualDaaScoreChangedRequestMessage{ID: id}
} }
// NotifyVirtualDaaScoreChangedResponseMessage is an appmessage corresponding to // NotifyVirtualDaaScoreChangedResponseMessage is an appmessage corresponding to
// its respective RPC message // its respective RPC message
type NotifyVirtualDaaScoreChangedResponseMessage struct { type NotifyVirtualDaaScoreChangedResponseMessage struct {
baseMessage baseMessage
ID string
Error *RPCError Error *RPCError
} }
@ -29,14 +31,15 @@ func (msg *NotifyVirtualDaaScoreChangedResponseMessage) Command() MessageCommand
} }
// NewNotifyVirtualDaaScoreChangedResponseMessage returns a instance of the message // NewNotifyVirtualDaaScoreChangedResponseMessage returns a instance of the message
func NewNotifyVirtualDaaScoreChangedResponseMessage() *NotifyVirtualDaaScoreChangedResponseMessage { func NewNotifyVirtualDaaScoreChangedResponseMessage(id string) *NotifyVirtualDaaScoreChangedResponseMessage {
return &NotifyVirtualDaaScoreChangedResponseMessage{} return &NotifyVirtualDaaScoreChangedResponseMessage{ID: id}
} }
// VirtualDaaScoreChangedNotificationMessage is an appmessage corresponding to // VirtualDaaScoreChangedNotificationMessage is an appmessage corresponding to
// its respective RPC message // its respective RPC message
type VirtualDaaScoreChangedNotificationMessage struct { type VirtualDaaScoreChangedNotificationMessage struct {
baseMessage baseMessage
ID string
VirtualDaaScore uint64 VirtualDaaScore uint64
} }
@ -47,9 +50,10 @@ func (msg *VirtualDaaScoreChangedNotificationMessage) Command() MessageCommand {
// NewVirtualDaaScoreChangedNotificationMessage returns a instance of the message // NewVirtualDaaScoreChangedNotificationMessage returns a instance of the message
func NewVirtualDaaScoreChangedNotificationMessage( func NewVirtualDaaScoreChangedNotificationMessage(
virtualDaaScore uint64) *VirtualDaaScoreChangedNotificationMessage { virtualDaaScore uint64, id string) *VirtualDaaScoreChangedNotificationMessage {
return &VirtualDaaScoreChangedNotificationMessage{ return &VirtualDaaScoreChangedNotificationMessage{
ID: id,
VirtualDaaScore: virtualDaaScore, VirtualDaaScore: virtualDaaScore,
} }
} }

View File

@ -4,6 +4,7 @@ package appmessage
// its respective RPC message // its respective RPC message
type NotifyVirtualSelectedParentBlueScoreChangedRequestMessage struct { type NotifyVirtualSelectedParentBlueScoreChangedRequestMessage struct {
baseMessage baseMessage
ID string
} }
// Command returns the protocol command string for the message // Command returns the protocol command string for the message
@ -12,14 +13,15 @@ func (msg *NotifyVirtualSelectedParentBlueScoreChangedRequestMessage) Command()
} }
// NewNotifyVirtualSelectedParentBlueScoreChangedRequestMessage returns a instance of the message // NewNotifyVirtualSelectedParentBlueScoreChangedRequestMessage returns a instance of the message
func NewNotifyVirtualSelectedParentBlueScoreChangedRequestMessage() *NotifyVirtualSelectedParentBlueScoreChangedRequestMessage { func NewNotifyVirtualSelectedParentBlueScoreChangedRequestMessage(id string) *NotifyVirtualSelectedParentBlueScoreChangedRequestMessage {
return &NotifyVirtualSelectedParentBlueScoreChangedRequestMessage{} return &NotifyVirtualSelectedParentBlueScoreChangedRequestMessage{ID: id}
} }
// NotifyVirtualSelectedParentBlueScoreChangedResponseMessage is an appmessage corresponding to // NotifyVirtualSelectedParentBlueScoreChangedResponseMessage is an appmessage corresponding to
// its respective RPC message // its respective RPC message
type NotifyVirtualSelectedParentBlueScoreChangedResponseMessage struct { type NotifyVirtualSelectedParentBlueScoreChangedResponseMessage struct {
baseMessage baseMessage
ID string
Error *RPCError Error *RPCError
} }
@ -29,14 +31,15 @@ func (msg *NotifyVirtualSelectedParentBlueScoreChangedResponseMessage) Command()
} }
// NewNotifyVirtualSelectedParentBlueScoreChangedResponseMessage returns a instance of the message // NewNotifyVirtualSelectedParentBlueScoreChangedResponseMessage returns a instance of the message
func NewNotifyVirtualSelectedParentBlueScoreChangedResponseMessage() *NotifyVirtualSelectedParentBlueScoreChangedResponseMessage { func NewNotifyVirtualSelectedParentBlueScoreChangedResponseMessage(id string) *NotifyVirtualSelectedParentBlueScoreChangedResponseMessage {
return &NotifyVirtualSelectedParentBlueScoreChangedResponseMessage{} return &NotifyVirtualSelectedParentBlueScoreChangedResponseMessage{ID: id}
} }
// VirtualSelectedParentBlueScoreChangedNotificationMessage is an appmessage corresponding to // VirtualSelectedParentBlueScoreChangedNotificationMessage is an appmessage corresponding to
// its respective RPC message // its respective RPC message
type VirtualSelectedParentBlueScoreChangedNotificationMessage struct { type VirtualSelectedParentBlueScoreChangedNotificationMessage struct {
baseMessage baseMessage
ID string
VirtualSelectedParentBlueScore uint64 VirtualSelectedParentBlueScore uint64
} }
@ -47,9 +50,10 @@ func (msg *VirtualSelectedParentBlueScoreChangedNotificationMessage) Command() M
// NewVirtualSelectedParentBlueScoreChangedNotificationMessage returns a instance of the message // NewVirtualSelectedParentBlueScoreChangedNotificationMessage returns a instance of the message
func NewVirtualSelectedParentBlueScoreChangedNotificationMessage( func NewVirtualSelectedParentBlueScoreChangedNotificationMessage(
virtualSelectedParentBlueScore uint64) *VirtualSelectedParentBlueScoreChangedNotificationMessage { virtualSelectedParentBlueScore uint64, id string) *VirtualSelectedParentBlueScoreChangedNotificationMessage {
return &VirtualSelectedParentBlueScoreChangedNotificationMessage{ return &VirtualSelectedParentBlueScoreChangedNotificationMessage{
ID: id,
VirtualSelectedParentBlueScore: virtualSelectedParentBlueScore, VirtualSelectedParentBlueScore: virtualSelectedParentBlueScore,
} }
} }

View File

@ -4,6 +4,7 @@ package appmessage
// its respective RPC message // its respective RPC message
type NotifyVirtualSelectedParentChainChangedRequestMessage struct { type NotifyVirtualSelectedParentChainChangedRequestMessage struct {
baseMessage baseMessage
ID string
IncludeAcceptedTransactionIDs bool IncludeAcceptedTransactionIDs bool
} }
@ -14,9 +15,10 @@ func (msg *NotifyVirtualSelectedParentChainChangedRequestMessage) Command() Mess
// NewNotifyVirtualSelectedParentChainChangedRequestMessage returns an instance of the message // NewNotifyVirtualSelectedParentChainChangedRequestMessage returns an instance of the message
func NewNotifyVirtualSelectedParentChainChangedRequestMessage( func NewNotifyVirtualSelectedParentChainChangedRequestMessage(
includeAcceptedTransactionIDs bool) *NotifyVirtualSelectedParentChainChangedRequestMessage { includeAcceptedTransactionIDs bool, id string) *NotifyVirtualSelectedParentChainChangedRequestMessage {
return &NotifyVirtualSelectedParentChainChangedRequestMessage{ return &NotifyVirtualSelectedParentChainChangedRequestMessage{
ID: id,
IncludeAcceptedTransactionIDs: includeAcceptedTransactionIDs, IncludeAcceptedTransactionIDs: includeAcceptedTransactionIDs,
} }
} }
@ -25,6 +27,7 @@ func NewNotifyVirtualSelectedParentChainChangedRequestMessage(
// its respective RPC message // its respective RPC message
type NotifyVirtualSelectedParentChainChangedResponseMessage struct { type NotifyVirtualSelectedParentChainChangedResponseMessage struct {
baseMessage baseMessage
ID string
Error *RPCError Error *RPCError
} }
@ -34,14 +37,15 @@ func (msg *NotifyVirtualSelectedParentChainChangedResponseMessage) Command() Mes
} }
// NewNotifyVirtualSelectedParentChainChangedResponseMessage returns a instance of the message // NewNotifyVirtualSelectedParentChainChangedResponseMessage returns a instance of the message
func NewNotifyVirtualSelectedParentChainChangedResponseMessage() *NotifyVirtualSelectedParentChainChangedResponseMessage { func NewNotifyVirtualSelectedParentChainChangedResponseMessage(id string) *NotifyVirtualSelectedParentChainChangedResponseMessage {
return &NotifyVirtualSelectedParentChainChangedResponseMessage{} return &NotifyVirtualSelectedParentChainChangedResponseMessage{ID: id}
} }
// VirtualSelectedParentChainChangedNotificationMessage is an appmessage corresponding to // VirtualSelectedParentChainChangedNotificationMessage is an appmessage corresponding to
// its respective RPC message // its respective RPC message
type VirtualSelectedParentChainChangedNotificationMessage struct { type VirtualSelectedParentChainChangedNotificationMessage struct {
baseMessage baseMessage
ID string
RemovedChainBlockHashes []string RemovedChainBlockHashes []string
AddedChainBlockHashes []string AddedChainBlockHashes []string
AcceptedTransactionIDs []*AcceptedTransactionIDs AcceptedTransactionIDs []*AcceptedTransactionIDs
@ -54,9 +58,10 @@ func (msg *VirtualSelectedParentChainChangedNotificationMessage) Command() Messa
// NewVirtualSelectedParentChainChangedNotificationMessage returns a instance of the message // NewVirtualSelectedParentChainChangedNotificationMessage returns a instance of the message
func NewVirtualSelectedParentChainChangedNotificationMessage(removedChainBlockHashes, func NewVirtualSelectedParentChainChangedNotificationMessage(removedChainBlockHashes,
addedChainBlocks []string, acceptedTransactionIDs []*AcceptedTransactionIDs) *VirtualSelectedParentChainChangedNotificationMessage { addedChainBlocks []string, acceptedTransactionIDs []*AcceptedTransactionIDs, id string) *VirtualSelectedParentChainChangedNotificationMessage {
return &VirtualSelectedParentChainChangedNotificationMessage{ return &VirtualSelectedParentChainChangedNotificationMessage{
ID: id,
RemovedChainBlockHashes: removedChainBlockHashes, RemovedChainBlockHashes: removedChainBlockHashes,
AddedChainBlockHashes: addedChainBlocks, AddedChainBlockHashes: addedChainBlocks,
AcceptedTransactionIDs: acceptedTransactionIDs, AcceptedTransactionIDs: acceptedTransactionIDs,

View File

@ -4,6 +4,7 @@ package appmessage
// its respective RPC message // its respective RPC message
type StopNotifyingUTXOsChangedRequestMessage struct { type StopNotifyingUTXOsChangedRequestMessage struct {
baseMessage baseMessage
ID string
Addresses []string Addresses []string
} }
@ -13,8 +14,9 @@ func (msg *StopNotifyingUTXOsChangedRequestMessage) Command() MessageCommand {
} }
// NewStopNotifyingUTXOsChangedRequestMessage returns a instance of the message // NewStopNotifyingUTXOsChangedRequestMessage returns a instance of the message
func NewStopNotifyingUTXOsChangedRequestMessage(addresses []string) *StopNotifyingUTXOsChangedRequestMessage { func NewStopNotifyingUTXOsChangedRequestMessage(addresses []string, id string) *StopNotifyingUTXOsChangedRequestMessage {
return &StopNotifyingUTXOsChangedRequestMessage{ return &StopNotifyingUTXOsChangedRequestMessage{
ID: id,
Addresses: addresses, Addresses: addresses,
} }
} }
@ -23,6 +25,7 @@ func NewStopNotifyingUTXOsChangedRequestMessage(addresses []string) *StopNotifyi
// its respective RPC message // its respective RPC message
type StopNotifyingUTXOsChangedResponseMessage struct { type StopNotifyingUTXOsChangedResponseMessage struct {
baseMessage baseMessage
ID string
Error *RPCError Error *RPCError
} }
@ -32,6 +35,6 @@ func (msg *StopNotifyingUTXOsChangedResponseMessage) Command() MessageCommand {
} }
// NewStopNotifyingUTXOsChangedResponseMessage returns a instance of the message // NewStopNotifyingUTXOsChangedResponseMessage returns a instance of the message
func NewStopNotifyingUTXOsChangedResponseMessage() *StopNotifyingUTXOsChangedResponseMessage { func NewStopNotifyingUTXOsChangedResponseMessage(id string) *StopNotifyingUTXOsChangedResponseMessage {
return &StopNotifyingUTXOsChangedResponseMessage{} return &StopNotifyingUTXOsChangedResponseMessage{ID: id}
} }

View File

@ -92,7 +92,7 @@ func (m *Manager) notifyBlockAddedToDAG(block *externalapi.DomainBlock) error {
if err != nil { if err != nil {
return err return err
} }
blockAddedNotification := appmessage.NewBlockAddedNotificationMessage(rpcBlock) blockAddedNotification := appmessage.NewBlockAddedNotificationMessage(rpcBlock, "")
err = m.context.NotificationManager.NotifyBlockAdded(blockAddedNotification) err = m.context.NotificationManager.NotifyBlockAdded(blockAddedNotification)
if err != nil { if err != nil {
return err return err
@ -141,7 +141,7 @@ func (m *Manager) notifyVirtualChange(virtualChangeSet *externalapi.VirtualChang
// NotifyNewBlockTemplate notifies the manager that a new // NotifyNewBlockTemplate notifies the manager that a new
// block template is available for miners // block template is available for miners
func (m *Manager) NotifyNewBlockTemplate() error { func (m *Manager) NotifyNewBlockTemplate() error {
notification := appmessage.NewNewBlockTemplateNotificationMessage() notification := appmessage.NewNewBlockTemplateNotificationMessage("")
return m.context.NotificationManager.NotifyNewBlockTemplate(notification) return m.context.NotificationManager.NotifyNewBlockTemplate(notification)
} }
@ -166,7 +166,7 @@ func (m *Manager) NotifyFinalityConflict(violatingBlockHash string) error {
onEnd := logger.LogAndMeasureExecutionTime(log, "RPCManager.NotifyFinalityConflict") onEnd := logger.LogAndMeasureExecutionTime(log, "RPCManager.NotifyFinalityConflict")
defer onEnd() defer onEnd()
notification := appmessage.NewFinalityConflictNotificationMessage(violatingBlockHash) notification := appmessage.NewFinalityConflictNotificationMessage(violatingBlockHash, rpccontext.DefaultNotificationID)
return m.context.NotificationManager.NotifyFinalityConflict(notification) return m.context.NotificationManager.NotifyFinalityConflict(notification)
} }
@ -175,7 +175,7 @@ func (m *Manager) NotifyFinalityConflictResolved(finalityBlockHash string) error
onEnd := logger.LogAndMeasureExecutionTime(log, "RPCManager.NotifyFinalityConflictResolved") onEnd := logger.LogAndMeasureExecutionTime(log, "RPCManager.NotifyFinalityConflictResolved")
defer onEnd() defer onEnd()
notification := appmessage.NewFinalityConflictResolvedNotificationMessage(finalityBlockHash) notification := appmessage.NewFinalityConflictResolvedNotificationMessage(finalityBlockHash, rpccontext.DefaultNotificationID)
return m.context.NotificationManager.NotifyFinalityConflictResolved(notification) return m.context.NotificationManager.NotifyFinalityConflictResolved(notification)
} }
@ -207,7 +207,7 @@ func (m *Manager) notifyVirtualSelectedParentBlueScoreChanged(virtualSelectedPar
onEnd := logger.LogAndMeasureExecutionTime(log, "RPCManager.NotifyVirtualSelectedParentBlueScoreChanged") onEnd := logger.LogAndMeasureExecutionTime(log, "RPCManager.NotifyVirtualSelectedParentBlueScoreChanged")
defer onEnd() defer onEnd()
notification := appmessage.NewVirtualSelectedParentBlueScoreChangedNotificationMessage(virtualSelectedParentBlueScore) notification := appmessage.NewVirtualSelectedParentBlueScoreChangedNotificationMessage(virtualSelectedParentBlueScore, rpccontext.DefaultNotificationID)
return m.context.NotificationManager.NotifyVirtualSelectedParentBlueScoreChanged(notification) return m.context.NotificationManager.NotifyVirtualSelectedParentBlueScoreChanged(notification)
} }
@ -215,7 +215,7 @@ func (m *Manager) notifyVirtualDaaScoreChanged(virtualDAAScore uint64) error {
onEnd := logger.LogAndMeasureExecutionTime(log, "RPCManager.NotifyVirtualDaaScoreChanged") onEnd := logger.LogAndMeasureExecutionTime(log, "RPCManager.NotifyVirtualDaaScoreChanged")
defer onEnd() defer onEnd()
notification := appmessage.NewVirtualDaaScoreChangedNotificationMessage(virtualDAAScore) notification := appmessage.NewVirtualDaaScoreChangedNotificationMessage(virtualDAAScore, rpccontext.DefaultNotificationID)
return m.context.NotificationManager.NotifyVirtualDaaScoreChanged(notification) return m.context.NotificationManager.NotifyVirtualDaaScoreChanged(notification)
} }
@ -236,7 +236,7 @@ func (m *Manager) notifyVirtualSelectedParentChainChanged(virtualChangeSet *exte
} }
notification, err := m.context.ConvertVirtualSelectedParentChainChangesToChainChangedNotificationMessage( notification, err := m.context.ConvertVirtualSelectedParentChainChangesToChainChangedNotificationMessage(
virtualChangeSet.VirtualSelectedParentChainChanges, includeAcceptedTransactionIDs) virtualChangeSet.VirtualSelectedParentChainChanges, includeAcceptedTransactionIDs, rpccontext.DefaultNotificationID) //DefaultNotificationId added in func
if err != nil { if err != nil {
return err return err
} }

View File

@ -9,7 +9,7 @@ import (
// ConvertVirtualSelectedParentChainChangesToChainChangedNotificationMessage converts // ConvertVirtualSelectedParentChainChangesToChainChangedNotificationMessage converts
// VirtualSelectedParentChainChanges to VirtualSelectedParentChainChangedNotificationMessage // VirtualSelectedParentChainChanges to VirtualSelectedParentChainChangedNotificationMessage
func (ctx *Context) ConvertVirtualSelectedParentChainChangesToChainChangedNotificationMessage( func (ctx *Context) ConvertVirtualSelectedParentChainChangesToChainChangedNotificationMessage(
selectedParentChainChanges *externalapi.SelectedChainPath, includeAcceptedTransactionIDs bool) ( selectedParentChainChanges *externalapi.SelectedChainPath, includeAcceptedTransactionIDs bool, id string) (
*appmessage.VirtualSelectedParentChainChangedNotificationMessage, error) { *appmessage.VirtualSelectedParentChainChangedNotificationMessage, error) {
removedChainBlockHashes := make([]string, len(selectedParentChainChanges.Removed)) removedChainBlockHashes := make([]string, len(selectedParentChainChanges.Removed))
@ -32,7 +32,7 @@ func (ctx *Context) ConvertVirtualSelectedParentChainChangesToChainChangedNotifi
} }
return appmessage.NewVirtualSelectedParentChainChangedNotificationMessage( return appmessage.NewVirtualSelectedParentChainChangedNotificationMessage(
removedChainBlockHashes, addedChainBlocks, acceptedTransactionIDs), nil removedChainBlockHashes, addedChainBlocks, acceptedTransactionIDs, id), nil
} }
func (ctx *Context) getAndConvertAcceptedTransactionIDs(selectedParentChainChanges *externalapi.SelectedChainPath) ( func (ctx *Context) getAndConvertAcceptedTransactionIDs(selectedParentChainChanges *externalapi.SelectedChainPath) (

View File

@ -14,6 +14,9 @@ import (
"github.com/pkg/errors" "github.com/pkg/errors"
) )
// DefaultNotificationID corrosponds to defualt grpc string value, and hence id value when not supplied, or as placeholder
const DefaultNotificationID string = ""
// NotificationManager manages notifications for the RPC // NotificationManager manages notifications for the RPC
type NotificationManager struct { type NotificationManager struct {
sync.RWMutex sync.RWMutex
@ -42,6 +45,16 @@ type NotificationListener struct {
propagatePruningPointUTXOSetOverrideNotifications bool propagatePruningPointUTXOSetOverrideNotifications bool
propagateNewBlockTemplateNotifications bool propagateNewBlockTemplateNotifications bool
propagateBlockAddedNotificationsID string
propagateVirtualSelectedParentChainChangedNotificationsID string
propagateFinalityConflictNotificationsID string
propagateFinalityConflictResolvedNotificationsID string
propagateUTXOsChangedNotificationsID string
propagateVirtualSelectedParentBlueScoreChangedNotificationsID string
propagateVirtualDaaScoreChangedNotificationsID string
propagatePruningPointUTXOSetOverrideNotificationsID string
propagateNewBlockTemplateNotificationsID string
propagateUTXOsChangedNotificationAddresses map[utxoindex.ScriptPublicKeyString]*UTXOsChangedNotificationAddress propagateUTXOsChangedNotificationAddresses map[utxoindex.ScriptPublicKeyString]*UTXOsChangedNotificationAddress
includeAcceptedTransactionIDsInVirtualSelectedParentChainChangedNotifications bool includeAcceptedTransactionIDsInVirtualSelectedParentChainChangedNotifications bool
} }
@ -103,6 +116,9 @@ func (nm *NotificationManager) NotifyBlockAdded(notification *appmessage.BlockAd
for router, listener := range nm.listeners { for router, listener := range nm.listeners {
if listener.propagateBlockAddedNotifications { if listener.propagateBlockAddedNotifications {
notification.ID = listener.propagateBlockAddedNotificationsID
err := router.OutgoingRoute().MaybeEnqueue(notification) err := router.OutgoingRoute().MaybeEnqueue(notification)
if err != nil { if err != nil {
return err return err
@ -120,6 +136,7 @@ func (nm *NotificationManager) NotifyVirtualSelectedParentChainChanged(
defer nm.RUnlock() defer nm.RUnlock()
notificationWithoutAcceptedTransactionIDs := &appmessage.VirtualSelectedParentChainChangedNotificationMessage{ notificationWithoutAcceptedTransactionIDs := &appmessage.VirtualSelectedParentChainChangedNotificationMessage{
ID: DefaultNotificationID,
RemovedChainBlockHashes: notification.RemovedChainBlockHashes, RemovedChainBlockHashes: notification.RemovedChainBlockHashes,
AddedChainBlockHashes: notification.AddedChainBlockHashes, AddedChainBlockHashes: notification.AddedChainBlockHashes,
} }
@ -129,8 +146,10 @@ func (nm *NotificationManager) NotifyVirtualSelectedParentChainChanged(
var err error var err error
if listener.includeAcceptedTransactionIDsInVirtualSelectedParentChainChangedNotifications { if listener.includeAcceptedTransactionIDsInVirtualSelectedParentChainChangedNotifications {
notification.ID = listener.propagateVirtualSelectedParentChainChangedNotificationsID
err = router.OutgoingRoute().MaybeEnqueue(notification) err = router.OutgoingRoute().MaybeEnqueue(notification)
} else { } else {
notificationWithoutAcceptedTransactionIDs.ID = listener.propagateVirtualSelectedParentChainChangedNotificationsID
err = router.OutgoingRoute().MaybeEnqueue(notificationWithoutAcceptedTransactionIDs) err = router.OutgoingRoute().MaybeEnqueue(notificationWithoutAcceptedTransactionIDs)
} }
@ -161,6 +180,9 @@ func (nm *NotificationManager) NotifyFinalityConflict(notification *appmessage.F
for router, listener := range nm.listeners { for router, listener := range nm.listeners {
if listener.propagateFinalityConflictNotifications { if listener.propagateFinalityConflictNotifications {
notification.ID = listener.propagateFinalityConflictNotificationsID
err := router.OutgoingRoute().Enqueue(notification) err := router.OutgoingRoute().Enqueue(notification)
if err != nil { if err != nil {
return err return err
@ -177,6 +199,9 @@ func (nm *NotificationManager) NotifyFinalityConflictResolved(notification *appm
for router, listener := range nm.listeners { for router, listener := range nm.listeners {
if listener.propagateFinalityConflictResolvedNotifications { if listener.propagateFinalityConflictResolvedNotifications {
notification.ID = listener.propagateFinalityConflictResolvedNotificationsID
err := router.OutgoingRoute().Enqueue(notification) err := router.OutgoingRoute().Enqueue(notification)
if err != nil { if err != nil {
return err return err
@ -194,7 +219,7 @@ func (nm *NotificationManager) NotifyUTXOsChanged(utxoChanges *utxoindex.UTXOCha
for router, listener := range nm.listeners { for router, listener := range nm.listeners {
if listener.propagateUTXOsChangedNotifications { if listener.propagateUTXOsChangedNotifications {
// Filter utxoChanges and create a notification // Filter utxoChanges and create a notification
notification, err := listener.convertUTXOChangesToUTXOsChangedNotification(utxoChanges) notification, err := listener.convertUTXOChangesToUTXOsChangedNotification(utxoChanges, listener.propagateUTXOsChangedNotificationsID)
if err != nil { if err != nil {
return err return err
} }
@ -224,6 +249,9 @@ func (nm *NotificationManager) NotifyVirtualSelectedParentBlueScoreChanged(
for router, listener := range nm.listeners { for router, listener := range nm.listeners {
if listener.propagateVirtualSelectedParentBlueScoreChangedNotifications { if listener.propagateVirtualSelectedParentBlueScoreChangedNotifications {
notification.ID = listener.propagateVirtualSelectedParentBlueScoreChangedNotificationsID
err := router.OutgoingRoute().MaybeEnqueue(notification) err := router.OutgoingRoute().MaybeEnqueue(notification)
if err != nil { if err != nil {
return err return err
@ -243,6 +271,9 @@ func (nm *NotificationManager) NotifyVirtualDaaScoreChanged(
for router, listener := range nm.listeners { for router, listener := range nm.listeners {
if listener.propagateVirtualDaaScoreChangedNotifications { if listener.propagateVirtualDaaScoreChangedNotifications {
notification.ID = listener.propagateVirtualDaaScoreChangedNotificationsID
err := router.OutgoingRoute().MaybeEnqueue(notification) err := router.OutgoingRoute().MaybeEnqueue(notification)
if err != nil { if err != nil {
return err return err
@ -262,6 +293,9 @@ func (nm *NotificationManager) NotifyNewBlockTemplate(
for router, listener := range nm.listeners { for router, listener := range nm.listeners {
if listener.propagateNewBlockTemplateNotifications { if listener.propagateNewBlockTemplateNotifications {
notification.ID = listener.propagateNewBlockTemplateNotificationsID
err := router.OutgoingRoute().Enqueue(notification) err := router.OutgoingRoute().Enqueue(notification)
if err != nil { if err != nil {
return err return err
@ -279,7 +313,7 @@ func (nm *NotificationManager) NotifyPruningPointUTXOSetOverride() error {
for router, listener := range nm.listeners { for router, listener := range nm.listeners {
if listener.propagatePruningPointUTXOSetOverrideNotifications { if listener.propagatePruningPointUTXOSetOverrideNotifications {
err := router.OutgoingRoute().Enqueue(appmessage.NewPruningPointUTXOSetOverrideNotificationMessage()) err := router.OutgoingRoute().Enqueue(appmessage.NewPruningPointUTXOSetOverrideNotificationMessage(listener.propagatePruningPointUTXOSetOverrideNotificationsID))
if err != nil { if err != nil {
return err return err
} }
@ -298,6 +332,7 @@ func newNotificationListener(params *dagconfig.Params) *NotificationListener {
propagateFinalityConflictResolvedNotifications: false, propagateFinalityConflictResolvedNotifications: false,
propagateUTXOsChangedNotifications: false, propagateUTXOsChangedNotifications: false,
propagateVirtualSelectedParentBlueScoreChangedNotifications: false, propagateVirtualSelectedParentBlueScoreChangedNotifications: false,
propagateVirtualDaaScoreChangedNotifications: false,
propagateNewBlockTemplateNotifications: false, propagateNewBlockTemplateNotifications: false,
propagatePruningPointUTXOSetOverrideNotifications: false, propagatePruningPointUTXOSetOverrideNotifications: false,
} }
@ -311,26 +346,30 @@ func (nl *NotificationListener) IncludeAcceptedTransactionIDsInVirtualSelectedPa
// PropagateBlockAddedNotifications instructs the listener to send block added notifications // PropagateBlockAddedNotifications instructs the listener to send block added notifications
// to the remote listener // to the remote listener
func (nl *NotificationListener) PropagateBlockAddedNotifications() { func (nl *NotificationListener) PropagateBlockAddedNotifications(id string) {
nl.propagateBlockAddedNotificationsID = id
nl.propagateBlockAddedNotifications = true nl.propagateBlockAddedNotifications = true
} }
// PropagateVirtualSelectedParentChainChangedNotifications instructs the listener to send chain changed notifications // PropagateVirtualSelectedParentChainChangedNotifications instructs the listener to send chain changed notifications
// to the remote listener // to the remote listener
func (nl *NotificationListener) PropagateVirtualSelectedParentChainChangedNotifications(includeAcceptedTransactionIDs bool) { func (nl *NotificationListener) PropagateVirtualSelectedParentChainChangedNotifications(includeAcceptedTransactionIDs bool, id string) {
nl.propagateVirtualSelectedParentChainChangedNotificationsID = id
nl.propagateVirtualSelectedParentChainChangedNotifications = true nl.propagateVirtualSelectedParentChainChangedNotifications = true
nl.includeAcceptedTransactionIDsInVirtualSelectedParentChainChangedNotifications = includeAcceptedTransactionIDs nl.includeAcceptedTransactionIDsInVirtualSelectedParentChainChangedNotifications = includeAcceptedTransactionIDs
} }
// PropagateFinalityConflictNotifications instructs the listener to send finality conflict notifications // PropagateFinalityConflictNotifications instructs the listener to send finality conflict notifications
// to the remote listener // to the remote listener
func (nl *NotificationListener) PropagateFinalityConflictNotifications() { func (nl *NotificationListener) PropagateFinalityConflictNotifications(id string) {
nl.propagateFinalityConflictNotificationsID = id
nl.propagateFinalityConflictNotifications = true nl.propagateFinalityConflictNotifications = true
} }
// PropagateFinalityConflictResolvedNotifications instructs the listener to send finality conflict resolved notifications // PropagateFinalityConflictResolvedNotifications instructs the listener to send finality conflict resolved notifications
// to the remote listener // to the remote listener
func (nl *NotificationListener) PropagateFinalityConflictResolvedNotifications() { func (nl *NotificationListener) PropagateFinalityConflictResolvedNotifications(id string) {
nl.propagateFinalityConflictResolvedNotificationsID = id
nl.propagateFinalityConflictResolvedNotifications = true nl.propagateFinalityConflictResolvedNotifications = true
} }
@ -338,8 +377,9 @@ func (nl *NotificationListener) PropagateFinalityConflictResolvedNotifications()
// to the remote listener for the given addresses. Subsequent calls instruct the listener to // to the remote listener for the given addresses. Subsequent calls instruct the listener to
// send UTXOs changed notifications for those addresses along with the old ones. Duplicate addresses // send UTXOs changed notifications for those addresses along with the old ones. Duplicate addresses
// are ignored. // are ignored.
func (nl *NotificationListener) PropagateUTXOsChangedNotifications(addresses []*UTXOsChangedNotificationAddress) { func (nl *NotificationListener) PropagateUTXOsChangedNotifications(addresses []*UTXOsChangedNotificationAddress, id string) {
if !nl.propagateUTXOsChangedNotifications { if !nl.propagateUTXOsChangedNotifications {
nl.propagateUTXOsChangedNotificationsID = id
nl.propagateUTXOsChangedNotifications = true nl.propagateUTXOsChangedNotifications = true
nl.propagateUTXOsChangedNotificationAddresses = nl.propagateUTXOsChangedNotificationAddresses =
make(map[utxoindex.ScriptPublicKeyString]*UTXOsChangedNotificationAddress, len(addresses)) make(map[utxoindex.ScriptPublicKeyString]*UTXOsChangedNotificationAddress, len(addresses))
@ -364,14 +404,15 @@ func (nl *NotificationListener) StopPropagatingUTXOsChangedNotifications(address
} }
func (nl *NotificationListener) convertUTXOChangesToUTXOsChangedNotification( 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 // As an optimization, we iterate over the smaller set (O(n)) among the two below
// and check existence over the larger set (O(1)) // and check existence over the larger set (O(1))
utxoChangesSize := len(utxoChanges.Added) + len(utxoChanges.Removed) utxoChangesSize := len(utxoChanges.Added) + len(utxoChanges.Removed)
addressesSize := len(nl.propagateUTXOsChangedNotificationAddresses) addressesSize := len(nl.propagateUTXOsChangedNotificationAddresses)
notification := &appmessage.UTXOsChangedNotificationMessage{} notification := &appmessage.UTXOsChangedNotificationMessage{ID: id}
if utxoChangesSize < addressesSize { if utxoChangesSize < addressesSize {
for scriptPublicKeyString, addedPairs := range utxoChanges.Added { for scriptPublicKeyString, addedPairs := range utxoChanges.Added {
if listenerAddress, ok := nl.propagateUTXOsChangedNotificationAddresses[scriptPublicKeyString]; ok { if listenerAddress, ok := nl.propagateUTXOsChangedNotificationAddresses[scriptPublicKeyString]; ok {
@ -441,30 +482,35 @@ func (nl *NotificationListener) scriptPubKeyStringToAddressString(scriptPublicKe
// PropagateVirtualSelectedParentBlueScoreChangedNotifications instructs the listener to send // PropagateVirtualSelectedParentBlueScoreChangedNotifications instructs the listener to send
// virtual selected parent blue score notifications to the remote listener // virtual selected parent blue score notifications to the remote listener
func (nl *NotificationListener) PropagateVirtualSelectedParentBlueScoreChangedNotifications() { func (nl *NotificationListener) PropagateVirtualSelectedParentBlueScoreChangedNotifications(id string) {
nl.propagateVirtualSelectedParentBlueScoreChangedNotificationsID = id
nl.propagateVirtualSelectedParentBlueScoreChangedNotifications = true nl.propagateVirtualSelectedParentBlueScoreChangedNotifications = true
} }
// PropagateVirtualDaaScoreChangedNotifications instructs the listener to send // PropagateVirtualDaaScoreChangedNotifications instructs the listener to send
// virtual DAA score notifications to the remote listener // virtual DAA score notifications to the remote listener
func (nl *NotificationListener) PropagateVirtualDaaScoreChangedNotifications() { func (nl *NotificationListener) PropagateVirtualDaaScoreChangedNotifications(id string) {
nl.propagateVirtualDaaScoreChangedNotificationsID = id
nl.propagateVirtualDaaScoreChangedNotifications = true nl.propagateVirtualDaaScoreChangedNotifications = true
} }
// PropagateNewBlockTemplateNotifications instructs the listener to send // PropagateNewBlockTemplateNotifications instructs the listener to send
// new block template notifications to the remote listener // new block template notifications to the remote listener
func (nl *NotificationListener) PropagateNewBlockTemplateNotifications() { func (nl *NotificationListener) PropagateNewBlockTemplateNotifications(id string) {
nl.propagateNewBlockTemplateNotificationsID = id
nl.propagateNewBlockTemplateNotifications = true nl.propagateNewBlockTemplateNotifications = true
} }
// PropagatePruningPointUTXOSetOverrideNotifications instructs the listener to send pruning point UTXO set override notifications // PropagatePruningPointUTXOSetOverrideNotifications instructs the listener to send pruning point UTXO set override notifications
// to the remote listener. // to the remote listener.
func (nl *NotificationListener) PropagatePruningPointUTXOSetOverrideNotifications() { func (nl *NotificationListener) PropagatePruningPointUTXOSetOverrideNotifications(id string) {
nl.propagatePruningPointUTXOSetOverrideNotificationsID = id
nl.propagatePruningPointUTXOSetOverrideNotifications = true nl.propagatePruningPointUTXOSetOverrideNotifications = true
} }
// StopPropagatingPruningPointUTXOSetOverrideNotifications instructs the listener to stop sending pruning // StopPropagatingPruningPointUTXOSetOverrideNotifications instructs the listener to stop sending pruning
// point UTXO set override notifications to the remote listener. // point UTXO set override notifications to the remote listener.
func (nl *NotificationListener) StopPropagatingPruningPointUTXOSetOverrideNotifications() { func (nl *NotificationListener) StopPropagatingPruningPointUTXOSetOverrideNotifications(id string) {
nl.propagatePruningPointUTXOSetOverrideNotificationsID = id
nl.propagatePruningPointUTXOSetOverrideNotifications = false nl.propagatePruningPointUTXOSetOverrideNotifications = false
} }

View File

@ -27,7 +27,7 @@ func HandleGetVirtualSelectedParentChainFromBlock(context *rpccontext.Context, _
} }
chainChangedNotification, err := context.ConvertVirtualSelectedParentChainChangesToChainChangedNotificationMessage( chainChangedNotification, err := context.ConvertVirtualSelectedParentChainChangesToChainChangedNotificationMessage(
virtualSelectedParentChain, getVirtualSelectedParentChainFromBlockRequest.IncludeAcceptedTransactionIDs) virtualSelectedParentChain, getVirtualSelectedParentChainFromBlockRequest.IncludeAcceptedTransactionIDs, rpccontext.DefaultNotificationID)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -7,13 +7,16 @@ import (
) )
// HandleNotifyBlockAdded handles the respectively named RPC command // HandleNotifyBlockAdded handles the respectively named RPC command
func HandleNotifyBlockAdded(context *rpccontext.Context, router *router.Router, _ appmessage.Message) (appmessage.Message, error) { func HandleNotifyBlockAdded(context *rpccontext.Context, router *router.Router, request appmessage.Message) (appmessage.Message, error) {
notifyBlockAddedRequestMessage := request.(*appmessage.NotifyBlockAddedRequestMessage)
listener, err := context.NotificationManager.Listener(router) listener, err := context.NotificationManager.Listener(router)
if err != nil { if err != nil {
return nil, err return nil, err
} }
listener.PropagateBlockAddedNotifications() listener.PropagateBlockAddedNotifications(notifyBlockAddedRequestMessage.ID)
response := appmessage.NewNotifyBlockAddedResponseMessage() response := appmessage.NewNotifyBlockAddedResponseMessage(notifyBlockAddedRequestMessage.ID)
return response, nil return response, nil
} }

View File

@ -7,14 +7,17 @@ import (
) )
// HandleNotifyFinalityConflicts handles the respectively named RPC command // HandleNotifyFinalityConflicts handles the respectively named RPC command
func HandleNotifyFinalityConflicts(context *rpccontext.Context, router *router.Router, _ appmessage.Message) (appmessage.Message, error) { func HandleNotifyFinalityConflicts(context *rpccontext.Context, router *router.Router, request appmessage.Message) (appmessage.Message, error) {
notifyFinalityConflictsRequest := request.(*appmessage.NotifyFinalityConflictsRequestMessage)
listener, err := context.NotificationManager.Listener(router) listener, err := context.NotificationManager.Listener(router)
if err != nil { if err != nil {
return nil, err return nil, err
} }
listener.PropagateFinalityConflictNotifications() listener.PropagateFinalityConflictNotifications(notifyFinalityConflictsRequest.ID)
listener.PropagateFinalityConflictResolvedNotifications() listener.PropagateFinalityConflictResolvedNotifications(notifyFinalityConflictsRequest.ID)
response := appmessage.NewNotifyFinalityConflictsResponseMessage() response := appmessage.NewNotifyFinalityConflictsResponseMessage(notifyFinalityConflictsRequest.ID)
return response, nil return response, nil
} }

View File

@ -7,13 +7,16 @@ import (
) )
// HandleNotifyNewBlockTemplate handles the respectively named RPC command // HandleNotifyNewBlockTemplate handles the respectively named RPC command
func HandleNotifyNewBlockTemplate(context *rpccontext.Context, router *router.Router, _ appmessage.Message) (appmessage.Message, error) { func HandleNotifyNewBlockTemplate(context *rpccontext.Context, router *router.Router, request appmessage.Message) (appmessage.Message, error) {
notifyNewBlockTemplateRequest := request.(*appmessage.NotifyNewBlockTemplateRequestMessage)
listener, err := context.NotificationManager.Listener(router) listener, err := context.NotificationManager.Listener(router)
if err != nil { if err != nil {
return nil, err return nil, err
} }
listener.PropagateNewBlockTemplateNotifications() listener.PropagateNewBlockTemplateNotifications(notifyNewBlockTemplateRequest.ID)
response := appmessage.NewNotifyNewBlockTemplateResponseMessage() response := appmessage.NewNotifyNewBlockTemplateResponseMessage(notifyNewBlockTemplateRequest.ID)
return response, nil return response, nil
} }

View File

@ -7,13 +7,16 @@ import (
) )
// HandleNotifyPruningPointUTXOSetOverrideRequest handles the respectively named RPC command // HandleNotifyPruningPointUTXOSetOverrideRequest handles the respectively named RPC command
func HandleNotifyPruningPointUTXOSetOverrideRequest(context *rpccontext.Context, router *router.Router, _ appmessage.Message) (appmessage.Message, error) { func HandleNotifyPruningPointUTXOSetOverrideRequest(context *rpccontext.Context, router *router.Router, request appmessage.Message) (appmessage.Message, error) {
notifyPruningPointUTXOSetOverrideRequest := request.(*appmessage.NotifyPruningPointUTXOSetOverrideRequestMessage)
listener, err := context.NotificationManager.Listener(router) listener, err := context.NotificationManager.Listener(router)
if err != nil { if err != nil {
return nil, err return nil, err
} }
listener.PropagatePruningPointUTXOSetOverrideNotifications() listener.PropagatePruningPointUTXOSetOverrideNotifications(notifyPruningPointUTXOSetOverrideRequest.ID)
response := appmessage.NewNotifyPruningPointUTXOSetOverrideResponseMessage() response := appmessage.NewNotifyPruningPointUTXOSetOverrideResponseMessage(notifyPruningPointUTXOSetOverrideRequest.ID)
return response, nil return response, nil
} }

View File

@ -8,16 +8,18 @@ import (
// HandleNotifyUTXOsChanged handles the respectively named RPC command // HandleNotifyUTXOsChanged handles the respectively named RPC command
func HandleNotifyUTXOsChanged(context *rpccontext.Context, router *router.Router, request appmessage.Message) (appmessage.Message, error) { func HandleNotifyUTXOsChanged(context *rpccontext.Context, router *router.Router, request appmessage.Message) (appmessage.Message, error) {
notifyUTXOsChangedRequest := request.(*appmessage.NotifyUTXOsChangedRequestMessage)
if !context.Config.UTXOIndex { if !context.Config.UTXOIndex {
errorMessage := appmessage.NewNotifyUTXOsChangedResponseMessage() errorMessage := appmessage.NewNotifyUTXOsChangedResponseMessage(notifyUTXOsChangedRequest.ID)
errorMessage.Error = appmessage.RPCErrorf("Method unavailable when kaspad is run without --utxoindex") errorMessage.Error = appmessage.RPCErrorf("Method unavailable when kaspad is run without --utxoindex")
return errorMessage, nil return errorMessage, nil
} }
notifyUTXOsChangedRequest := request.(*appmessage.NotifyUTXOsChangedRequestMessage)
addresses, err := context.ConvertAddressStringsToUTXOsChangedNotificationAddresses(notifyUTXOsChangedRequest.Addresses) addresses, err := context.ConvertAddressStringsToUTXOsChangedNotificationAddresses(notifyUTXOsChangedRequest.Addresses)
if err != nil { if err != nil {
errorMessage := appmessage.NewNotifyUTXOsChangedResponseMessage() errorMessage := appmessage.NewNotifyUTXOsChangedResponseMessage(notifyUTXOsChangedRequest.ID)
errorMessage.Error = appmessage.RPCErrorf("Parsing error: %s", err) errorMessage.Error = appmessage.RPCErrorf("Parsing error: %s", err)
return errorMessage, nil return errorMessage, nil
} }
@ -26,8 +28,8 @@ func HandleNotifyUTXOsChanged(context *rpccontext.Context, router *router.Router
if err != nil { if err != nil {
return nil, err return nil, err
} }
listener.PropagateUTXOsChangedNotifications(addresses) listener.PropagateUTXOsChangedNotifications(addresses, notifyUTXOsChangedRequest.ID)
response := appmessage.NewNotifyUTXOsChangedResponseMessage() response := appmessage.NewNotifyUTXOsChangedResponseMessage(notifyUTXOsChangedRequest.ID)
return response, nil return response, nil
} }

View File

@ -7,13 +7,16 @@ import (
) )
// HandleNotifyVirtualDaaScoreChanged handles the respectively named RPC command // HandleNotifyVirtualDaaScoreChanged handles the respectively named RPC command
func HandleNotifyVirtualDaaScoreChanged(context *rpccontext.Context, router *router.Router, _ appmessage.Message) (appmessage.Message, error) { func HandleNotifyVirtualDaaScoreChanged(context *rpccontext.Context, router *router.Router, request appmessage.Message) (appmessage.Message, error) {
notifyVirtualDaaScoreChangedRequest := request.(*appmessage.NotifyVirtualDaaScoreChangedRequestMessage)
listener, err := context.NotificationManager.Listener(router) listener, err := context.NotificationManager.Listener(router)
if err != nil { if err != nil {
return nil, err return nil, err
} }
listener.PropagateVirtualDaaScoreChangedNotifications() listener.PropagateVirtualDaaScoreChangedNotifications(notifyVirtualDaaScoreChangedRequest.ID)
response := appmessage.NewNotifyVirtualDaaScoreChangedResponseMessage() response := appmessage.NewNotifyVirtualDaaScoreChangedResponseMessage(notifyVirtualDaaScoreChangedRequest.ID)
return response, nil return response, nil
} }

View File

@ -7,13 +7,16 @@ import (
) )
// HandleNotifyVirtualSelectedParentBlueScoreChanged handles the respectively named RPC command // HandleNotifyVirtualSelectedParentBlueScoreChanged handles the respectively named RPC command
func HandleNotifyVirtualSelectedParentBlueScoreChanged(context *rpccontext.Context, router *router.Router, _ appmessage.Message) (appmessage.Message, error) { func HandleNotifyVirtualSelectedParentBlueScoreChanged(context *rpccontext.Context, router *router.Router, request appmessage.Message) (appmessage.Message, error) {
notifyVirtualSelectedParentBlueScoreChangedRequest := request.(*appmessage.NotifyVirtualSelectedParentBlueScoreChangedRequestMessage)
listener, err := context.NotificationManager.Listener(router) listener, err := context.NotificationManager.Listener(router)
if err != nil { if err != nil {
return nil, err return nil, err
} }
listener.PropagateVirtualSelectedParentBlueScoreChangedNotifications() listener.PropagateVirtualSelectedParentBlueScoreChangedNotifications(notifyVirtualSelectedParentBlueScoreChangedRequest.ID)
response := appmessage.NewNotifyVirtualSelectedParentBlueScoreChangedResponseMessage() response := appmessage.NewNotifyVirtualSelectedParentBlueScoreChangedResponseMessage(notifyVirtualSelectedParentBlueScoreChangedRequest.ID)
return response, nil return response, nil
} }

View File

@ -17,8 +17,9 @@ func HandleNotifyVirtualSelectedParentChainChanged(context *rpccontext.Context,
return nil, err return nil, err
} }
listener.PropagateVirtualSelectedParentChainChangedNotifications( listener.PropagateVirtualSelectedParentChainChangedNotifications(
notifyVirtualSelectedParentChainChangedRequest.IncludeAcceptedTransactionIDs) notifyVirtualSelectedParentChainChangedRequest.IncludeAcceptedTransactionIDs,
notifyVirtualSelectedParentChainChangedRequest.ID)
response := appmessage.NewNotifyVirtualSelectedParentChainChangedResponseMessage() response := appmessage.NewNotifyVirtualSelectedParentChainChangedResponseMessage(notifyVirtualSelectedParentChainChangedRequest.ID)
return response, nil return response, nil
} }

View File

@ -7,13 +7,16 @@ import (
) )
// HandleStopNotifyingPruningPointUTXOSetOverrideRequest handles the respectively named RPC command // HandleStopNotifyingPruningPointUTXOSetOverrideRequest handles the respectively named RPC command
func HandleStopNotifyingPruningPointUTXOSetOverrideRequest(context *rpccontext.Context, router *router.Router, _ appmessage.Message) (appmessage.Message, error) { func HandleStopNotifyingPruningPointUTXOSetOverrideRequest(context *rpccontext.Context, router *router.Router, request appmessage.Message) (appmessage.Message, error) {
stopNotifyingPruningPointUTXOSetOverrideRequest := request.(*appmessage.StopNotifyingPruningPointUTXOSetOverrideRequestMessage)
listener, err := context.NotificationManager.Listener(router) listener, err := context.NotificationManager.Listener(router)
if err != nil { if err != nil {
return nil, err return nil, err
} }
listener.StopPropagatingPruningPointUTXOSetOverrideNotifications() listener.StopPropagatingPruningPointUTXOSetOverrideNotifications(stopNotifyingPruningPointUTXOSetOverrideRequest.ID)
response := appmessage.NewStopNotifyingPruningPointUTXOSetOverrideResponseMessage() response := appmessage.NewStopNotifyingPruningPointUTXOSetOverrideResponseMessage(stopNotifyingPruningPointUTXOSetOverrideRequest.ID)
return response, nil return response, nil
} }

View File

@ -8,16 +8,18 @@ import (
// HandleStopNotifyingUTXOsChanged handles the respectively named RPC command // HandleStopNotifyingUTXOsChanged handles the respectively named RPC command
func HandleStopNotifyingUTXOsChanged(context *rpccontext.Context, router *router.Router, request appmessage.Message) (appmessage.Message, error) { func HandleStopNotifyingUTXOsChanged(context *rpccontext.Context, router *router.Router, request appmessage.Message) (appmessage.Message, error) {
stopNotifyingUTXOsChangedRequest := request.(*appmessage.StopNotifyingUTXOsChangedRequestMessage)
if !context.Config.UTXOIndex { if !context.Config.UTXOIndex {
errorMessage := appmessage.NewStopNotifyingUTXOsChangedResponseMessage() errorMessage := appmessage.NewStopNotifyingUTXOsChangedResponseMessage(stopNotifyingUTXOsChangedRequest.ID)
errorMessage.Error = appmessage.RPCErrorf("Method unavailable when kaspad is run without --utxoindex") errorMessage.Error = appmessage.RPCErrorf("Method unavailable when kaspad is run without --utxoindex")
return errorMessage, nil return errorMessage, nil
} }
stopNotifyingUTXOsChangedRequest := request.(*appmessage.StopNotifyingUTXOsChangedRequestMessage)
addresses, err := context.ConvertAddressStringsToUTXOsChangedNotificationAddresses(stopNotifyingUTXOsChangedRequest.Addresses) addresses, err := context.ConvertAddressStringsToUTXOsChangedNotificationAddresses(stopNotifyingUTXOsChangedRequest.Addresses)
if err != nil { if err != nil {
errorMessage := appmessage.NewNotifyUTXOsChangedResponseMessage() errorMessage := appmessage.NewNotifyUTXOsChangedResponseMessage(stopNotifyingUTXOsChangedRequest.ID)
errorMessage.Error = appmessage.RPCErrorf("Parsing error: %s", err) errorMessage.Error = appmessage.RPCErrorf("Parsing error: %s", err)
return errorMessage, nil return errorMessage, nil
} }
@ -28,6 +30,6 @@ func HandleStopNotifyingUTXOsChanged(context *rpccontext.Context, router *router
} }
listener.StopPropagatingUTXOsChangedNotifications(addresses) listener.StopPropagatingUTXOsChangedNotifications(addresses)
response := appmessage.NewStopNotifyingUTXOsChangedResponseMessage() response := appmessage.NewStopNotifyingUTXOsChangedResponseMessage(stopNotifyingUTXOsChangedRequest.ID)
return response, nil return response, nil
} }

View File

@ -492,6 +492,11 @@ NotifyBlockAddedRequestMessage registers this connection for blockAdded notifica
See: BlockAddedNotificationMessage See: BlockAddedNotificationMessage
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| id | [string](#string) | | |
@ -504,6 +509,7 @@ See: BlockAddedNotificationMessage
| Field | Type | Label | Description | | Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- | | ----- | ---- | ----- | ----------- |
| id | [string](#string) | | |
| error | [RPCError](#protowire.RPCError) | | | | error | [RPCError](#protowire.RPCError) | | |
@ -522,6 +528,7 @@ See: NotifyBlockAddedRequestMessage
| Field | Type | Label | Description | | Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- | | ----- | ---- | ----- | ----------- |
| id | [string](#string) | | |
| block | [RpcBlock](#protowire.RpcBlock) | | | | block | [RpcBlock](#protowire.RpcBlock) | | |
@ -807,6 +814,7 @@ See: VirtualSelectedParentChainChangedNotificationMessage
| Field | Type | Label | Description | | Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- | | ----- | ---- | ----- | ----------- |
| id | [string](#string) | | |
| includeAcceptedTransactionIds | [bool](#bool) | | | | includeAcceptedTransactionIds | [bool](#bool) | | |
@ -822,6 +830,7 @@ See: VirtualSelectedParentChainChangedNotificationMessage
| Field | Type | Label | Description | | Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- | | ----- | ---- | ----- | ----------- |
| id | [string](#string) | | |
| error | [RPCError](#protowire.RPCError) | | | | error | [RPCError](#protowire.RPCError) | | |
@ -840,6 +849,7 @@ See: NotifyVirtualSelectedParentChainChangedRequestMessage
| Field | Type | Label | Description | | Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- | | ----- | ---- | ----- | ----------- |
| id | [string](#string) | | |
| removedChainBlockHashes | [string](#string) | repeated | The chain blocks that were removed, in high-to-low order | | removedChainBlockHashes | [string](#string) | repeated | The chain blocks that were removed, in high-to-low order |
| addedChainBlockHashes | [string](#string) | repeated | The chain blocks that were added, in low-to-high order | | addedChainBlockHashes | [string](#string) | repeated | The chain blocks that were added, in low-to-high order |
| acceptedTransactionIds | [AcceptedTransactionIds](#protowire.AcceptedTransactionIds) | repeated | Will be filled only if `includeAcceptedTransactionIds = true` in the notify request. | | acceptedTransactionIds | [AcceptedTransactionIds](#protowire.AcceptedTransactionIds) | repeated | Will be filled only if `includeAcceptedTransactionIds = true` in the notify request. |
@ -1099,6 +1109,11 @@ of this kaspad&#39;s DAG.
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| id | [string](#string) | | |
@ -1111,6 +1126,7 @@ of this kaspad&#39;s DAG.
| Field | Type | Label | Description | | Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- | | ----- | ---- | ----- | ----------- |
| id | [string](#string) | | |
| error | [RPCError](#protowire.RPCError) | | | | error | [RPCError](#protowire.RPCError) | | |
@ -1126,6 +1142,7 @@ of this kaspad&#39;s DAG.
| Field | Type | Label | Description | | Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- | | ----- | ---- | ----- | ----------- |
| id | [string](#string) | | |
| violatingBlockHash | [string](#string) | | | | violatingBlockHash | [string](#string) | | |
@ -1141,6 +1158,7 @@ of this kaspad&#39;s DAG.
| Field | Type | Label | Description | | Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- | | ----- | ---- | ----- | ----------- |
| id | [string](#string) | | |
| finalityBlockHash | [string](#string) | | | | finalityBlockHash | [string](#string) | | |
@ -1220,6 +1238,7 @@ See: UtxosChangedNotificationMessage
| Field | Type | Label | Description | | Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- | | ----- | ---- | ----- | ----------- |
| id | [string](#string) | | |
| addresses | [string](#string) | repeated | Leave empty to get all updates | | addresses | [string](#string) | repeated | Leave empty to get all updates |
@ -1235,6 +1254,7 @@ See: UtxosChangedNotificationMessage
| Field | Type | Label | Description | | Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- | | ----- | ---- | ----- | ----------- |
| id | [string](#string) | | |
| error | [RPCError](#protowire.RPCError) | | | | error | [RPCError](#protowire.RPCError) | | |
@ -1252,6 +1272,7 @@ See: NotifyUtxosChangedRequestMessage
| Field | Type | Label | Description | | Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- | | ----- | ---- | ----- | ----------- |
| id | [string](#string) | | |
| added | [UtxosByAddressesEntry](#protowire.UtxosByAddressesEntry) | repeated | | | added | [UtxosByAddressesEntry](#protowire.UtxosByAddressesEntry) | repeated | |
| removed | [UtxosByAddressesEntry](#protowire.UtxosByAddressesEntry) | repeated | | | removed | [UtxosByAddressesEntry](#protowire.UtxosByAddressesEntry) | repeated | |
@ -1290,6 +1311,7 @@ See: UtxosChangedNotificationMessage
| Field | Type | Label | Description | | Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- | | ----- | ---- | ----- | ----------- |
| id | [string](#string) | | |
| addresses | [string](#string) | repeated | | | addresses | [string](#string) | repeated | |
@ -1305,6 +1327,7 @@ See: UtxosChangedNotificationMessage
| Field | Type | Label | Description | | Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- | | ----- | ---- | ----- | ----------- |
| id | [string](#string) | | |
| error | [RPCError](#protowire.RPCError) | | | | error | [RPCError](#protowire.RPCError) | | |
@ -1462,6 +1485,11 @@ virtualSelectedParentBlueScoreChanged notifications.
See: VirtualSelectedParentBlueScoreChangedNotificationMessage See: VirtualSelectedParentBlueScoreChangedNotificationMessage
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| id | [string](#string) | | |
@ -1474,6 +1502,7 @@ See: VirtualSelectedParentBlueScoreChangedNotificationMessage
| Field | Type | Label | Description | | Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- | | ----- | ---- | ----- | ----------- |
| id | [string](#string) | | |
| error | [RPCError](#protowire.RPCError) | | | | error | [RPCError](#protowire.RPCError) | | |
@ -1492,6 +1521,7 @@ See NotifyVirtualSelectedParentBlueScoreChangedRequestMessage
| Field | Type | Label | Description | | Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- | | ----- | ---- | ----- | ----------- |
| id | [string](#string) | | |
| virtualSelectedParentBlueScore | [uint64](#uint64) | | | | virtualSelectedParentBlueScore | [uint64](#uint64) | | |
@ -1508,6 +1538,11 @@ virtualDaaScoreChanged notifications.
See: VirtualDaaScoreChangedNotificationMessage See: VirtualDaaScoreChangedNotificationMessage
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| id | [string](#string) | | |
@ -1520,6 +1555,7 @@ See: VirtualDaaScoreChangedNotificationMessage
| Field | Type | Label | Description | | Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- | | ----- | ---- | ----- | ----------- |
| id | [string](#string) | | |
| error | [RPCError](#protowire.RPCError) | | | | error | [RPCError](#protowire.RPCError) | | |
@ -1538,6 +1574,7 @@ See NotifyVirtualDaaScoreChangedRequestMessage
| Field | Type | Label | Description | | Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- | | ----- | ---- | ----- | ----------- |
| id | [string](#string) | | |
| virtualDaaScore | [uint64](#uint64) | | | | virtualDaaScore | [uint64](#uint64) | | |
@ -1556,6 +1593,11 @@ This call is only available when this kaspad was started with `--utxoindex`
See: NotifyPruningPointUTXOSetOverrideResponseMessage See: NotifyPruningPointUTXOSetOverrideResponseMessage
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| id | [string](#string) | | |
@ -1568,6 +1610,7 @@ See: NotifyPruningPointUTXOSetOverrideResponseMessage
| Field | Type | Label | Description | | Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- | | ----- | ---- | ----- | ----------- |
| id | [string](#string) | | |
| error | [RPCError](#protowire.RPCError) | | | | error | [RPCError](#protowire.RPCError) | | |
@ -1584,6 +1627,11 @@ resets due to pruning point change via IBD.
See NotifyPruningPointUTXOSetOverrideRequestMessage See NotifyPruningPointUTXOSetOverrideRequestMessage
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| id | [string](#string) | | |
@ -1599,6 +1647,11 @@ This call is only available when this kaspad was started with `--utxoindex`
See: PruningPointUTXOSetOverrideNotificationMessage See: PruningPointUTXOSetOverrideNotificationMessage
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| id | [string](#string) | | |
@ -1611,6 +1664,7 @@ See: PruningPointUTXOSetOverrideNotificationMessage
| Field | Type | Label | Description | | Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- | | ----- | ---- | ----- | ----------- |
| id | [string](#string) | | |
| error | [RPCError](#protowire.RPCError) | | | | error | [RPCError](#protowire.RPCError) | | |
@ -1749,6 +1803,11 @@ NewBlockTemplate notifications.
See: NewBlockTemplateNotificationMessage See: NewBlockTemplateNotificationMessage
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| id | [string](#string) | | |
@ -1761,6 +1820,7 @@ See: NewBlockTemplateNotificationMessage
| Field | Type | Label | Description | | Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- | | ----- | ---- | ----- | ----------- |
| id | [string](#string) | | |
| error | [RPCError](#protowire.RPCError) | | | | error | [RPCError](#protowire.RPCError) | | |
@ -1777,6 +1837,11 @@ available for miners.
See NotifyNewBlockTemplateRequestMessage See NotifyNewBlockTemplateRequestMessage
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| id | [string](#string) | | |

View File

@ -171,9 +171,12 @@ message GetBlockTemplateResponseMessage{
// //
// See: BlockAddedNotificationMessage // See: BlockAddedNotificationMessage
message NotifyBlockAddedRequestMessage{ message NotifyBlockAddedRequestMessage{
string id = 1001;
} }
message NotifyBlockAddedResponseMessage{ message NotifyBlockAddedResponseMessage{
string id = 1001;
RPCError error = 1000; RPCError error = 1000;
} }
@ -182,6 +185,7 @@ message NotifyBlockAddedResponseMessage{
// //
// See: NotifyBlockAddedRequestMessage // See: NotifyBlockAddedRequestMessage
message BlockAddedNotificationMessage{ message BlockAddedNotificationMessage{
string id = 1001;
RpcBlock block = 3; RpcBlock block = 3;
} }
@ -306,10 +310,12 @@ message SubmitTransactionResponseMessage{
// //
// See: VirtualSelectedParentChainChangedNotificationMessage // See: VirtualSelectedParentChainChangedNotificationMessage
message NotifyVirtualSelectedParentChainChangedRequestMessage{ message NotifyVirtualSelectedParentChainChangedRequestMessage{
string id = 1001;
bool includeAcceptedTransactionIds = 1; bool includeAcceptedTransactionIds = 1;
} }
message NotifyVirtualSelectedParentChainChangedResponseMessage{ message NotifyVirtualSelectedParentChainChangedResponseMessage{
string id = 1001;
RPCError error = 1000; RPCError error = 1000;
} }
@ -318,7 +324,9 @@ message NotifyVirtualSelectedParentChainChangedResponseMessage{
// //
// See: NotifyVirtualSelectedParentChainChangedRequestMessage // See: NotifyVirtualSelectedParentChainChangedRequestMessage
message VirtualSelectedParentChainChangedNotificationMessage{ message VirtualSelectedParentChainChangedNotificationMessage{
// The chain blocks that were removed, in high-to-low order string id = 1001;
// The chain blocks that were removed, in high-to-low order
repeated string removedChainBlockHashes = 1; repeated string removedChainBlockHashes = 1;
// The chain blocks that were added, in low-to-high order // The chain blocks that were added, in low-to-high order
@ -432,17 +440,21 @@ message ResolveFinalityConflictResponseMessage{
} }
message NotifyFinalityConflictsRequestMessage{ message NotifyFinalityConflictsRequestMessage{
string id = 1001;
} }
message NotifyFinalityConflictsResponseMessage{ message NotifyFinalityConflictsResponseMessage{
string id = 1001;
RPCError error = 1000; RPCError error = 1000;
} }
message FinalityConflictNotificationMessage{ message FinalityConflictNotificationMessage{
string id = 1001;
string violatingBlockHash = 1; string violatingBlockHash = 1;
} }
message FinalityConflictResolvedNotificationMessage{ message FinalityConflictResolvedNotificationMessage{
string id = 1001;
string finalityBlockHash = 1; string finalityBlockHash = 1;
} }
@ -474,10 +486,12 @@ message GetHeadersResponseMessage{
// //
// See: UtxosChangedNotificationMessage // See: UtxosChangedNotificationMessage
message NotifyUtxosChangedRequestMessage { message NotifyUtxosChangedRequestMessage {
string id = 1001;
repeated string addresses = 1; // Leave empty to get all updates repeated string addresses = 1; // Leave empty to get all updates
} }
message NotifyUtxosChangedResponseMessage { message NotifyUtxosChangedResponseMessage {
string id = 1001;
RPCError error = 1000; RPCError error = 1000;
} }
@ -485,6 +499,7 @@ message NotifyUtxosChangedResponseMessage {
// //
// See: NotifyUtxosChangedRequestMessage // See: NotifyUtxosChangedRequestMessage
message UtxosChangedNotificationMessage { message UtxosChangedNotificationMessage {
string id = 1001;
repeated UtxosByAddressesEntry added = 1; repeated UtxosByAddressesEntry added = 1;
repeated UtxosByAddressesEntry removed = 2; repeated UtxosByAddressesEntry removed = 2;
} }
@ -502,10 +517,12 @@ message UtxosByAddressesEntry {
// //
// See: UtxosChangedNotificationMessage // See: UtxosChangedNotificationMessage
message StopNotifyingUtxosChangedRequestMessage { message StopNotifyingUtxosChangedRequestMessage {
string id = 1001;
repeated string addresses = 1; repeated string addresses = 1;
} }
message StopNotifyingUtxosChangedResponseMessage { message StopNotifyingUtxosChangedResponseMessage {
string id = 1001;
RPCError error = 1000; RPCError error = 1000;
} }
@ -568,9 +585,11 @@ message GetVirtualSelectedParentBlueScoreResponseMessage {
// //
// See: VirtualSelectedParentBlueScoreChangedNotificationMessage // See: VirtualSelectedParentBlueScoreChangedNotificationMessage
message NotifyVirtualSelectedParentBlueScoreChangedRequestMessage { message NotifyVirtualSelectedParentBlueScoreChangedRequestMessage {
string id = 1001;
} }
message NotifyVirtualSelectedParentBlueScoreChangedResponseMessage { message NotifyVirtualSelectedParentBlueScoreChangedResponseMessage {
string id = 1001;
RPCError error = 1000; RPCError error = 1000;
} }
@ -579,6 +598,7 @@ message NotifyVirtualSelectedParentBlueScoreChangedResponseMessage {
// //
// See NotifyVirtualSelectedParentBlueScoreChangedRequestMessage // See NotifyVirtualSelectedParentBlueScoreChangedRequestMessage
message VirtualSelectedParentBlueScoreChangedNotificationMessage { message VirtualSelectedParentBlueScoreChangedNotificationMessage {
string id = 1001;
uint64 virtualSelectedParentBlueScore = 1; uint64 virtualSelectedParentBlueScore = 1;
} }
@ -587,9 +607,11 @@ message VirtualSelectedParentBlueScoreChangedNotificationMessage {
// //
// See: VirtualDaaScoreChangedNotificationMessage // See: VirtualDaaScoreChangedNotificationMessage
message NotifyVirtualDaaScoreChangedRequestMessage { message NotifyVirtualDaaScoreChangedRequestMessage {
string id = 1001;
} }
message NotifyVirtualDaaScoreChangedResponseMessage { message NotifyVirtualDaaScoreChangedResponseMessage {
string id = 1001;
RPCError error = 1000; RPCError error = 1000;
} }
@ -598,6 +620,7 @@ message NotifyVirtualDaaScoreChangedResponseMessage {
// //
// See NotifyVirtualDaaScoreChangedRequestMessage // See NotifyVirtualDaaScoreChangedRequestMessage
message VirtualDaaScoreChangedNotificationMessage { message VirtualDaaScoreChangedNotificationMessage {
string id = 1001;
uint64 virtualDaaScore = 1; uint64 virtualDaaScore = 1;
} }
@ -608,10 +631,12 @@ message VirtualDaaScoreChangedNotificationMessage {
// //
// See: NotifyPruningPointUTXOSetOverrideResponseMessage // See: NotifyPruningPointUTXOSetOverrideResponseMessage
message NotifyPruningPointUTXOSetOverrideRequestMessage { message NotifyPruningPointUTXOSetOverrideRequestMessage {
string id = 1001;
} }
message NotifyPruningPointUTXOSetOverrideResponseMessage { message NotifyPruningPointUTXOSetOverrideResponseMessage {
string id = 1001;
RPCError error = 1000; RPCError error = 1000;
} }
@ -620,6 +645,7 @@ message NotifyPruningPointUTXOSetOverrideResponseMessage {
// //
// See NotifyPruningPointUTXOSetOverrideRequestMessage // See NotifyPruningPointUTXOSetOverrideRequestMessage
message PruningPointUTXOSetOverrideNotificationMessage { message PruningPointUTXOSetOverrideNotificationMessage {
string id = 1001;
} }
// StopNotifyingPruningPointUTXOSetOverrideRequestMessage unregisters this connection for // StopNotifyingPruningPointUTXOSetOverrideRequestMessage unregisters this connection for
@ -629,9 +655,11 @@ message PruningPointUTXOSetOverrideNotificationMessage {
// //
// See: PruningPointUTXOSetOverrideNotificationMessage // See: PruningPointUTXOSetOverrideNotificationMessage
message StopNotifyingPruningPointUTXOSetOverrideRequestMessage { message StopNotifyingPruningPointUTXOSetOverrideRequestMessage {
string id = 1001;
} }
message StopNotifyingPruningPointUTXOSetOverrideResponseMessage { message StopNotifyingPruningPointUTXOSetOverrideResponseMessage {
string id = 1001;
RPCError error = 1000; RPCError error = 1000;
} }
@ -681,9 +709,11 @@ message EstimateNetworkHashesPerSecondResponseMessage{
// //
// See: NewBlockTemplateNotificationMessage // See: NewBlockTemplateNotificationMessage
message NotifyNewBlockTemplateRequestMessage { message NotifyNewBlockTemplateRequestMessage {
string id = 1001;
} }
message NotifyNewBlockTemplateResponseMessage { message NotifyNewBlockTemplateResponseMessage {
string id = 1001;
RPCError error = 1000; RPCError error = 1000;
} }
@ -692,6 +722,7 @@ message NotifyNewBlockTemplateResponseMessage {
// //
// See NotifyNewBlockTemplateRequestMessage // See NotifyNewBlockTemplateRequestMessage
message NewBlockTemplateNotificationMessage { message NewBlockTemplateNotificationMessage {
string id = 1001;
} }
message MempoolEntryByAddress{ message MempoolEntryByAddress{

View File

@ -6,14 +6,26 @@ import (
) )
func (x *KaspadMessage_NotifyBlockAddedRequest) toAppMessage() (appmessage.Message, error) { func (x *KaspadMessage_NotifyBlockAddedRequest) toAppMessage() (appmessage.Message, error) {
return &appmessage.NotifyBlockAddedRequestMessage{}, nil if x == nil {
return nil, errors.Wrapf(errorNil, "KaspadMessage_NotifyBlockAddedRequest is nil")
}
return x.NotifyBlockAddedRequest.toAppMessage()
} }
func (x *KaspadMessage_NotifyBlockAddedRequest) fromAppMessage(_ *appmessage.NotifyBlockAddedRequestMessage) error { func (x *KaspadMessage_NotifyBlockAddedRequest) fromAppMessage(message *appmessage.NotifyBlockAddedRequestMessage) error {
x.NotifyBlockAddedRequest = &NotifyBlockAddedRequestMessage{} x.NotifyBlockAddedRequest = &NotifyBlockAddedRequestMessage{Id: message.ID}
return nil return nil
} }
func (x *NotifyBlockAddedRequestMessage) toAppMessage() (appmessage.Message, error) {
if x == nil {
return nil, errors.Wrapf(errorNil, "NotifyBlockAddedRequest is nil")
}
return &appmessage.NotifyBlockAddedRequestMessage{
ID: x.Id,
}, nil
}
func (x *KaspadMessage_NotifyBlockAddedResponse) toAppMessage() (appmessage.Message, error) { func (x *KaspadMessage_NotifyBlockAddedResponse) toAppMessage() (appmessage.Message, error) {
if x == nil { if x == nil {
return nil, errors.Wrapf(errorNil, "KaspadMessage_NotifyBlockAddedResponse is nil") return nil, errors.Wrapf(errorNil, "KaspadMessage_NotifyBlockAddedResponse is nil")
@ -27,6 +39,7 @@ func (x *KaspadMessage_NotifyBlockAddedResponse) fromAppMessage(message *appmess
err = &RPCError{Message: message.Error.Message} err = &RPCError{Message: message.Error.Message}
} }
x.NotifyBlockAddedResponse = &NotifyBlockAddedResponseMessage{ x.NotifyBlockAddedResponse = &NotifyBlockAddedResponseMessage{
Id: message.ID,
Error: err, Error: err,
} }
return nil return nil
@ -42,6 +55,7 @@ func (x *NotifyBlockAddedResponseMessage) toAppMessage() (appmessage.Message, er
return nil, err return nil, err
} }
return &appmessage.NotifyBlockAddedResponseMessage{ return &appmessage.NotifyBlockAddedResponseMessage{
ID: x.Id,
Error: rpcErr, Error: rpcErr,
}, nil }, nil
} }
@ -60,6 +74,7 @@ func (x *KaspadMessage_BlockAddedNotification) fromAppMessage(message *appmessag
return err return err
} }
x.BlockAddedNotification = &BlockAddedNotificationMessage{ x.BlockAddedNotification = &BlockAddedNotificationMessage{
Id: message.ID,
Block: block, Block: block,
} }
return nil return nil
@ -74,6 +89,7 @@ func (x *BlockAddedNotificationMessage) toAppMessage() (appmessage.Message, erro
return nil, err return nil, err
} }
return &appmessage.BlockAddedNotificationMessage{ return &appmessage.BlockAddedNotificationMessage{
ID: x.Id,
Block: block, Block: block,
}, nil }, nil
} }

View File

@ -6,14 +6,26 @@ import (
) )
func (x *KaspadMessage_NotifyFinalityConflictsRequest) toAppMessage() (appmessage.Message, error) { func (x *KaspadMessage_NotifyFinalityConflictsRequest) toAppMessage() (appmessage.Message, error) {
return &appmessage.NotifyFinalityConflictsRequestMessage{}, nil if x == nil {
return nil, errors.Wrapf(errorNil, "KaspadMessage_NotifyFinalityConflictsRequest is nil")
}
return x.NotifyFinalityConflictsRequest.toAppMessage()
} }
func (x *KaspadMessage_NotifyFinalityConflictsRequest) fromAppMessage(_ *appmessage.NotifyFinalityConflictsRequestMessage) error { func (x *KaspadMessage_NotifyFinalityConflictsRequest) fromAppMessage(message *appmessage.NotifyFinalityConflictsRequestMessage) error {
x.NotifyFinalityConflictsRequest = &NotifyFinalityConflictsRequestMessage{} x.NotifyFinalityConflictsRequest = &NotifyFinalityConflictsRequestMessage{Id: message.ID}
return nil return nil
} }
func (x *NotifyFinalityConflictsRequestMessage) toAppMessage() (appmessage.Message, error) {
if x == nil {
return nil, errors.Wrapf(errorNil, "NotifyFinalityConflictsRequestMessage is nil")
}
return &appmessage.NotifyFinalityConflictsRequestMessage{
ID: x.Id,
}, nil
}
func (x *KaspadMessage_NotifyFinalityConflictsResponse) toAppMessage() (appmessage.Message, error) { func (x *KaspadMessage_NotifyFinalityConflictsResponse) toAppMessage() (appmessage.Message, error) {
if x == nil { if x == nil {
return nil, errors.Wrapf(errorNil, "KaspadMessage_NotifyFinalityConflictsResponse is nil") return nil, errors.Wrapf(errorNil, "KaspadMessage_NotifyFinalityConflictsResponse is nil")
@ -27,6 +39,7 @@ func (x *KaspadMessage_NotifyFinalityConflictsResponse) fromAppMessage(message *
err = &RPCError{Message: message.Error.Message} err = &RPCError{Message: message.Error.Message}
} }
x.NotifyFinalityConflictsResponse = &NotifyFinalityConflictsResponseMessage{ x.NotifyFinalityConflictsResponse = &NotifyFinalityConflictsResponseMessage{
Id: message.ID,
Error: err, Error: err,
} }
return nil return nil
@ -42,6 +55,7 @@ func (x *NotifyFinalityConflictsResponseMessage) toAppMessage() (appmessage.Mess
return nil, err return nil, err
} }
return &appmessage.NotifyFinalityConflictsResponseMessage{ return &appmessage.NotifyFinalityConflictsResponseMessage{
ID: x.Id,
Error: rpcErr, Error: rpcErr,
}, nil }, nil
} }
@ -55,6 +69,7 @@ func (x *KaspadMessage_FinalityConflictNotification) toAppMessage() (appmessage.
func (x *KaspadMessage_FinalityConflictNotification) fromAppMessage(message *appmessage.FinalityConflictNotificationMessage) error { func (x *KaspadMessage_FinalityConflictNotification) fromAppMessage(message *appmessage.FinalityConflictNotificationMessage) error {
x.FinalityConflictNotification = &FinalityConflictNotificationMessage{ x.FinalityConflictNotification = &FinalityConflictNotificationMessage{
Id: message.ID,
ViolatingBlockHash: message.ViolatingBlockHash, ViolatingBlockHash: message.ViolatingBlockHash,
} }
return nil return nil
@ -65,6 +80,7 @@ func (x *FinalityConflictNotificationMessage) toAppMessage() (appmessage.Message
return nil, errors.Wrapf(errorNil, "FinalityConflictNotificationMessage is nil") return nil, errors.Wrapf(errorNil, "FinalityConflictNotificationMessage is nil")
} }
return &appmessage.FinalityConflictNotificationMessage{ return &appmessage.FinalityConflictNotificationMessage{
ID: x.Id,
ViolatingBlockHash: x.ViolatingBlockHash, ViolatingBlockHash: x.ViolatingBlockHash,
}, nil }, nil
} }
@ -78,6 +94,7 @@ func (x *KaspadMessage_FinalityConflictResolvedNotification) toAppMessage() (app
func (x *KaspadMessage_FinalityConflictResolvedNotification) fromAppMessage(message *appmessage.FinalityConflictResolvedNotificationMessage) error { func (x *KaspadMessage_FinalityConflictResolvedNotification) fromAppMessage(message *appmessage.FinalityConflictResolvedNotificationMessage) error {
x.FinalityConflictResolvedNotification = &FinalityConflictResolvedNotificationMessage{ x.FinalityConflictResolvedNotification = &FinalityConflictResolvedNotificationMessage{
Id: message.ID,
FinalityBlockHash: message.FinalityBlockHash, FinalityBlockHash: message.FinalityBlockHash,
} }
return nil return nil
@ -88,6 +105,7 @@ func (x *FinalityConflictResolvedNotificationMessage) toAppMessage() (appmessage
return nil, errors.Wrapf(errorNil, "FinalityConflictResolvedNotificationMessage is nil") return nil, errors.Wrapf(errorNil, "FinalityConflictResolvedNotificationMessage is nil")
} }
return &appmessage.FinalityConflictResolvedNotificationMessage{ return &appmessage.FinalityConflictResolvedNotificationMessage{
ID: x.Id,
FinalityBlockHash: x.FinalityBlockHash, FinalityBlockHash: x.FinalityBlockHash,
}, nil }, nil
} }

View File

@ -6,14 +6,26 @@ import (
) )
func (x *KaspadMessage_NotifyNewBlockTemplateRequest) toAppMessage() (appmessage.Message, error) { func (x *KaspadMessage_NotifyNewBlockTemplateRequest) toAppMessage() (appmessage.Message, error) {
return &appmessage.NotifyNewBlockTemplateRequestMessage{}, nil if x == nil {
return nil, errors.Wrapf(errorNil, "KaspadMessage_NotifyNewBlockTemplateRequest is nil")
}
return x.NotifyNewBlockTemplateRequest.toAppMessage()
} }
func (x *KaspadMessage_NotifyNewBlockTemplateRequest) fromAppMessage(_ *appmessage.NotifyNewBlockTemplateRequestMessage) error { func (x *KaspadMessage_NotifyNewBlockTemplateRequest) fromAppMessage(message *appmessage.NotifyNewBlockTemplateRequestMessage) error {
x.NotifyNewBlockTemplateRequest = &NotifyNewBlockTemplateRequestMessage{} x.NotifyNewBlockTemplateRequest = &NotifyNewBlockTemplateRequestMessage{Id: message.ID}
return nil return nil
} }
func (x *NotifyNewBlockTemplateRequestMessage) toAppMessage() (appmessage.Message, error) {
if x == nil {
return nil, errors.Wrapf(errorNil, "NotifyNewBlockTemplateRequestMessage is nil")
}
return &appmessage.NotifyNewBlockTemplateRequestMessage{
ID: x.Id,
}, nil
}
func (x *KaspadMessage_NotifyNewBlockTemplateResponse) toAppMessage() (appmessage.Message, error) { func (x *KaspadMessage_NotifyNewBlockTemplateResponse) toAppMessage() (appmessage.Message, error) {
if x == nil { if x == nil {
return nil, errors.Wrapf(errorNil, "KaspadMessage_NotifyNewBlockTemplateResponse is nil") return nil, errors.Wrapf(errorNil, "KaspadMessage_NotifyNewBlockTemplateResponse is nil")
@ -27,6 +39,7 @@ func (x *KaspadMessage_NotifyNewBlockTemplateResponse) fromAppMessage(message *a
err = &RPCError{Message: message.Error.Message} err = &RPCError{Message: message.Error.Message}
} }
x.NotifyNewBlockTemplateResponse = &NotifyNewBlockTemplateResponseMessage{ x.NotifyNewBlockTemplateResponse = &NotifyNewBlockTemplateResponseMessage{
Id: message.ID,
Error: err, Error: err,
} }
return nil return nil
@ -42,6 +55,7 @@ func (x *NotifyNewBlockTemplateResponseMessage) toAppMessage() (appmessage.Messa
return nil, err return nil, err
} }
return &appmessage.NotifyNewBlockTemplateResponseMessage{ return &appmessage.NotifyNewBlockTemplateResponseMessage{
ID: x.Id,
Error: rpcErr, Error: rpcErr,
}, nil }, nil
} }
@ -54,7 +68,7 @@ func (x *KaspadMessage_NewBlockTemplateNotification) toAppMessage() (appmessage.
} }
func (x *KaspadMessage_NewBlockTemplateNotification) fromAppMessage(message *appmessage.NewBlockTemplateNotificationMessage) error { func (x *KaspadMessage_NewBlockTemplateNotification) fromAppMessage(message *appmessage.NewBlockTemplateNotificationMessage) error {
x.NewBlockTemplateNotification = &NewBlockTemplateNotificationMessage{} x.NewBlockTemplateNotification = &NewBlockTemplateNotificationMessage{Id: message.ID}
return nil return nil
} }
@ -62,5 +76,5 @@ func (x *NewBlockTemplateNotificationMessage) toAppMessage() (appmessage.Message
if x == nil { if x == nil {
return nil, errors.Wrapf(errorNil, "NewBlockTemplateNotificationMessage is nil") return nil, errors.Wrapf(errorNil, "NewBlockTemplateNotificationMessage is nil")
} }
return &appmessage.NewBlockTemplateNotificationMessage{}, nil return &appmessage.NewBlockTemplateNotificationMessage{ID: x.Id}, nil
} }

View File

@ -9,7 +9,7 @@ func (x *KaspadMessage_NotifyPruningPointUTXOSetOverrideRequest) toAppMessage()
if x == nil { if x == nil {
return nil, errors.Wrapf(errorNil, "KaspadMessage_NotifyPruningPointUTXOSetOverrideRequest is nil") return nil, errors.Wrapf(errorNil, "KaspadMessage_NotifyPruningPointUTXOSetOverrideRequest is nil")
} }
return &appmessage.NotifyPruningPointUTXOSetOverrideRequestMessage{}, nil return x.NotifyPruningPointUTXOSetOverrideRequest.toAppMessage()
} }
func (x *KaspadMessage_NotifyPruningPointUTXOSetOverrideRequest) fromAppMessage(_ *appmessage.NotifyPruningPointUTXOSetOverrideRequestMessage) error { func (x *KaspadMessage_NotifyPruningPointUTXOSetOverrideRequest) fromAppMessage(_ *appmessage.NotifyPruningPointUTXOSetOverrideRequestMessage) error {
@ -17,6 +17,15 @@ func (x *KaspadMessage_NotifyPruningPointUTXOSetOverrideRequest) fromAppMessage(
return nil return nil
} }
func (x *NotifyPruningPointUTXOSetOverrideRequestMessage) toAppMessage() (appmessage.Message, error) {
if x == nil {
return nil, errors.Wrapf(errorNil, "NotifyPruningPointUTXOSetOverrideRequestMessage is nil")
}
return &appmessage.NotifyPruningPointUTXOSetOverrideRequestMessage{
ID: x.Id,
}, nil
}
func (x *KaspadMessage_NotifyPruningPointUTXOSetOverrideResponse) toAppMessage() (appmessage.Message, error) { func (x *KaspadMessage_NotifyPruningPointUTXOSetOverrideResponse) toAppMessage() (appmessage.Message, error) {
if x == nil { if x == nil {
return nil, errors.Wrapf(errorNil, "KaspadMessage_NotifyPruningPointUTXOSetOverrideResponse is nil") return nil, errors.Wrapf(errorNil, "KaspadMessage_NotifyPruningPointUTXOSetOverrideResponse is nil")
@ -30,6 +39,7 @@ func (x *KaspadMessage_NotifyPruningPointUTXOSetOverrideResponse) fromAppMessage
err = &RPCError{Message: message.Error.Message} err = &RPCError{Message: message.Error.Message}
} }
x.NotifyPruningPointUTXOSetOverrideResponse = &NotifyPruningPointUTXOSetOverrideResponseMessage{ x.NotifyPruningPointUTXOSetOverrideResponse = &NotifyPruningPointUTXOSetOverrideResponseMessage{
Id: message.ID,
Error: err, Error: err,
} }
return nil return nil
@ -45,6 +55,7 @@ func (x *NotifyPruningPointUTXOSetOverrideResponseMessage) toAppMessage() (appme
return nil, err return nil, err
} }
return &appmessage.NotifyPruningPointUTXOSetOverrideResponseMessage{ return &appmessage.NotifyPruningPointUTXOSetOverrideResponseMessage{
ID: x.Id,
Error: rpcErr, Error: rpcErr,
}, nil }, nil
} }
@ -53,11 +64,11 @@ func (x *KaspadMessage_PruningPointUTXOSetOverrideNotification) toAppMessage() (
if x == nil { if x == nil {
return nil, errors.Wrapf(errorNil, "KaspadMessage_PruningPointUTXOSetOverrideNotification is nil") return nil, errors.Wrapf(errorNil, "KaspadMessage_PruningPointUTXOSetOverrideNotification is nil")
} }
return &appmessage.PruningPointUTXOSetOverrideNotificationMessage{}, nil return &appmessage.PruningPointUTXOSetOverrideNotificationMessage{ID: x.PruningPointUTXOSetOverrideNotification.Id}, nil
} }
func (x *KaspadMessage_PruningPointUTXOSetOverrideNotification) fromAppMessage(_ *appmessage.PruningPointUTXOSetOverrideNotificationMessage) error { func (x *KaspadMessage_PruningPointUTXOSetOverrideNotification) fromAppMessage(message *appmessage.PruningPointUTXOSetOverrideNotificationMessage) error {
x.PruningPointUTXOSetOverrideNotification = &PruningPointUTXOSetOverrideNotificationMessage{} x.PruningPointUTXOSetOverrideNotification = &PruningPointUTXOSetOverrideNotificationMessage{Id: message.ID}
return nil return nil
} }
@ -65,14 +76,23 @@ func (x *KaspadMessage_StopNotifyingPruningPointUTXOSetOverrideRequest) toAppMes
if x == nil { if x == nil {
return nil, errors.Wrapf(errorNil, "KaspadMessage_StopNotifyingPruningPointUTXOSetOverrideRequest is nil") return nil, errors.Wrapf(errorNil, "KaspadMessage_StopNotifyingPruningPointUTXOSetOverrideRequest is nil")
} }
return &appmessage.StopNotifyingPruningPointUTXOSetOverrideRequestMessage{}, nil return x.StopNotifyingPruningPointUTXOSetOverrideRequest.toAppMessage()
} }
func (x *KaspadMessage_StopNotifyingPruningPointUTXOSetOverrideRequest) fromAppMessage(_ *appmessage.StopNotifyingPruningPointUTXOSetOverrideRequestMessage) error { func (x *KaspadMessage_StopNotifyingPruningPointUTXOSetOverrideRequest) fromAppMessage(message *appmessage.StopNotifyingPruningPointUTXOSetOverrideRequestMessage) error {
x.StopNotifyingPruningPointUTXOSetOverrideRequest = &StopNotifyingPruningPointUTXOSetOverrideRequestMessage{} x.StopNotifyingPruningPointUTXOSetOverrideRequest = &StopNotifyingPruningPointUTXOSetOverrideRequestMessage{Id: message.ID}
return nil return nil
} }
func (x *StopNotifyingPruningPointUTXOSetOverrideRequestMessage) toAppMessage() (appmessage.Message, error) {
if x == nil {
return nil, errors.Wrapf(errorNil, "StopNotifyingPruningPointUTXOSetOverrideRequestMessage is nil")
}
return &appmessage.StopNotifyingPruningPointUTXOSetOverrideRequestMessage{
ID: x.Id,
}, nil
}
func (x *KaspadMessage_StopNotifyingPruningPointUTXOSetOverrideResponse) toAppMessage() (appmessage.Message, error) { func (x *KaspadMessage_StopNotifyingPruningPointUTXOSetOverrideResponse) toAppMessage() (appmessage.Message, error) {
if x == nil { if x == nil {
return nil, errors.Wrapf(errorNil, "KaspadMessage_StopNotifyingPruningPointUTXOSetOverrideResponse is nil") return nil, errors.Wrapf(errorNil, "KaspadMessage_StopNotifyingPruningPointUTXOSetOverrideResponse is nil")
@ -88,6 +108,7 @@ func (x *KaspadMessage_StopNotifyingPruningPointUTXOSetOverrideResponse) fromApp
err = &RPCError{Message: message.Error.Message} err = &RPCError{Message: message.Error.Message}
} }
x.StopNotifyingPruningPointUTXOSetOverrideResponse = &StopNotifyingPruningPointUTXOSetOverrideResponseMessage{ x.StopNotifyingPruningPointUTXOSetOverrideResponse = &StopNotifyingPruningPointUTXOSetOverrideResponseMessage{
Id: message.ID,
Error: err, Error: err,
} }
return nil return nil
@ -103,6 +124,7 @@ func (x *StopNotifyingPruningPointUTXOSetOverrideResponseMessage) toAppMessage()
return nil, err return nil, err
} }
return &appmessage.StopNotifyingPruningPointUTXOSetOverrideResponseMessage{ return &appmessage.StopNotifyingPruningPointUTXOSetOverrideResponseMessage{
ID: x.Id,
Error: rpcErr, Error: rpcErr,
}, nil }, nil
} }

View File

@ -14,6 +14,7 @@ func (x *KaspadMessage_NotifyUtxosChangedRequest) toAppMessage() (appmessage.Mes
func (x *KaspadMessage_NotifyUtxosChangedRequest) fromAppMessage(message *appmessage.NotifyUTXOsChangedRequestMessage) error { func (x *KaspadMessage_NotifyUtxosChangedRequest) fromAppMessage(message *appmessage.NotifyUTXOsChangedRequestMessage) error {
x.NotifyUtxosChangedRequest = &NotifyUtxosChangedRequestMessage{ x.NotifyUtxosChangedRequest = &NotifyUtxosChangedRequestMessage{
Id: message.ID,
Addresses: message.Addresses, Addresses: message.Addresses,
} }
return nil return nil
@ -24,6 +25,7 @@ func (x *NotifyUtxosChangedRequestMessage) toAppMessage() (appmessage.Message, e
return nil, errors.Wrapf(errorNil, "NotifyUtxosChangedRequestMessage is nil") return nil, errors.Wrapf(errorNil, "NotifyUtxosChangedRequestMessage is nil")
} }
return &appmessage.NotifyUTXOsChangedRequestMessage{ return &appmessage.NotifyUTXOsChangedRequestMessage{
ID: x.Id,
Addresses: x.Addresses, Addresses: x.Addresses,
}, nil }, nil
} }
@ -41,6 +43,7 @@ func (x *KaspadMessage_NotifyUtxosChangedResponse) fromAppMessage(message *appme
err = &RPCError{Message: message.Error.Message} err = &RPCError{Message: message.Error.Message}
} }
x.NotifyUtxosChangedResponse = &NotifyUtxosChangedResponseMessage{ x.NotifyUtxosChangedResponse = &NotifyUtxosChangedResponseMessage{
Id: message.ID,
Error: err, Error: err,
} }
return nil return nil
@ -56,6 +59,7 @@ func (x *NotifyUtxosChangedResponseMessage) toAppMessage() (appmessage.Message,
return nil, err return nil, err
} }
return &appmessage.NotifyUTXOsChangedResponseMessage{ return &appmessage.NotifyUTXOsChangedResponseMessage{
ID: x.Id,
Error: rpcErr, Error: rpcErr,
}, nil }, nil
} }
@ -81,6 +85,7 @@ func (x *KaspadMessage_UtxosChangedNotification) fromAppMessage(message *appmess
} }
x.UtxosChangedNotification = &UtxosChangedNotificationMessage{ x.UtxosChangedNotification = &UtxosChangedNotificationMessage{
Id: message.ID,
Added: added, Added: added,
Removed: removed, Removed: removed,
} }
@ -114,6 +119,7 @@ func (x *UtxosChangedNotificationMessage) toAppMessage() (appmessage.Message, er
} }
return &appmessage.UTXOsChangedNotificationMessage{ return &appmessage.UTXOsChangedNotificationMessage{
ID: x.Id,
Added: added, Added: added,
Removed: removed, Removed: removed,
}, nil }, nil

View File

@ -9,14 +9,21 @@ func (x *KaspadMessage_NotifyVirtualDaaScoreChangedRequest) toAppMessage() (appm
if x == nil { if x == nil {
return nil, errors.Wrapf(errorNil, "KaspadMessage_NotifyVirtualDaaScoreChangedRequest is nil") return nil, errors.Wrapf(errorNil, "KaspadMessage_NotifyVirtualDaaScoreChangedRequest is nil")
} }
return &appmessage.NotifyVirtualDaaScoreChangedRequestMessage{}, nil return x.NotifyVirtualDaaScoreChangedRequest.toAppMessage()
} }
func (x *KaspadMessage_NotifyVirtualDaaScoreChangedRequest) fromAppMessage(_ *appmessage.NotifyVirtualDaaScoreChangedRequestMessage) error { func (x *KaspadMessage_NotifyVirtualDaaScoreChangedRequest) fromAppMessage(message *appmessage.NotifyVirtualDaaScoreChangedRequestMessage) error {
x.NotifyVirtualDaaScoreChangedRequest = &NotifyVirtualDaaScoreChangedRequestMessage{} x.NotifyVirtualDaaScoreChangedRequest = &NotifyVirtualDaaScoreChangedRequestMessage{Id: message.ID}
return nil return nil
} }
func (x *NotifyVirtualDaaScoreChangedRequestMessage) toAppMessage() (appmessage.Message, error) {
if x == nil {
return nil, errors.Wrapf(errorNil, "NotifyVirtualDaaScoreChangedRequestMessage is nil")
}
return &appmessage.NotifyVirtualDaaScoreChangedRequestMessage{ID: x.Id}, nil
}
func (x *KaspadMessage_NotifyVirtualDaaScoreChangedResponse) toAppMessage() (appmessage.Message, error) { func (x *KaspadMessage_NotifyVirtualDaaScoreChangedResponse) toAppMessage() (appmessage.Message, error) {
if x == nil { if x == nil {
return nil, errors.Wrapf(errorNil, "KaspadMessage_NotifyVirtualDaaScoreChangedResponse is nil") return nil, errors.Wrapf(errorNil, "KaspadMessage_NotifyVirtualDaaScoreChangedResponse is nil")
@ -30,6 +37,7 @@ func (x *KaspadMessage_NotifyVirtualDaaScoreChangedResponse) fromAppMessage(mess
err = &RPCError{Message: message.Error.Message} err = &RPCError{Message: message.Error.Message}
} }
x.NotifyVirtualDaaScoreChangedResponse = &NotifyVirtualDaaScoreChangedResponseMessage{ x.NotifyVirtualDaaScoreChangedResponse = &NotifyVirtualDaaScoreChangedResponseMessage{
Id: message.ID,
Error: err, Error: err,
} }
return nil return nil
@ -45,6 +53,7 @@ func (x *NotifyVirtualDaaScoreChangedResponseMessage) toAppMessage() (appmessage
return nil, err return nil, err
} }
return &appmessage.NotifyVirtualDaaScoreChangedResponseMessage{ return &appmessage.NotifyVirtualDaaScoreChangedResponseMessage{
ID: x.Id,
Error: rpcErr, Error: rpcErr,
}, nil }, nil
} }
@ -58,6 +67,7 @@ func (x *KaspadMessage_VirtualDaaScoreChangedNotification) toAppMessage() (appme
func (x *KaspadMessage_VirtualDaaScoreChangedNotification) fromAppMessage(message *appmessage.VirtualDaaScoreChangedNotificationMessage) error { func (x *KaspadMessage_VirtualDaaScoreChangedNotification) fromAppMessage(message *appmessage.VirtualDaaScoreChangedNotificationMessage) error {
x.VirtualDaaScoreChangedNotification = &VirtualDaaScoreChangedNotificationMessage{ x.VirtualDaaScoreChangedNotification = &VirtualDaaScoreChangedNotificationMessage{
Id: message.ID,
VirtualDaaScore: message.VirtualDaaScore, VirtualDaaScore: message.VirtualDaaScore,
} }
return nil return nil
@ -68,6 +78,7 @@ func (x *VirtualDaaScoreChangedNotificationMessage) toAppMessage() (appmessage.M
return nil, errors.Wrapf(errorNil, "VirtualDaaScoreChangedNotificationMessage is nil") return nil, errors.Wrapf(errorNil, "VirtualDaaScoreChangedNotificationMessage is nil")
} }
return &appmessage.VirtualDaaScoreChangedNotificationMessage{ return &appmessage.VirtualDaaScoreChangedNotificationMessage{
ID: x.Id,
VirtualDaaScore: x.VirtualDaaScore, VirtualDaaScore: x.VirtualDaaScore,
}, nil }, nil
} }

View File

@ -9,14 +9,23 @@ func (x *KaspadMessage_NotifyVirtualSelectedParentBlueScoreChangedRequest) toApp
if x == nil { if x == nil {
return nil, errors.Wrapf(errorNil, "KaspadMessage_NotifyVirtualSelectedParentBlueScoreChangedRequest is nil") return nil, errors.Wrapf(errorNil, "KaspadMessage_NotifyVirtualSelectedParentBlueScoreChangedRequest is nil")
} }
return &appmessage.NotifyVirtualSelectedParentBlueScoreChangedRequestMessage{}, nil return x.NotifyVirtualSelectedParentBlueScoreChangedRequest.toAppMessage()
} }
func (x *KaspadMessage_NotifyVirtualSelectedParentBlueScoreChangedRequest) fromAppMessage(_ *appmessage.NotifyVirtualSelectedParentBlueScoreChangedRequestMessage) error { func (x *KaspadMessage_NotifyVirtualSelectedParentBlueScoreChangedRequest) fromAppMessage(message *appmessage.NotifyVirtualSelectedParentBlueScoreChangedRequestMessage) error {
x.NotifyVirtualSelectedParentBlueScoreChangedRequest = &NotifyVirtualSelectedParentBlueScoreChangedRequestMessage{} x.NotifyVirtualSelectedParentBlueScoreChangedRequest = &NotifyVirtualSelectedParentBlueScoreChangedRequestMessage{
Id: message.ID,
}
return nil return nil
} }
func (x *NotifyVirtualSelectedParentBlueScoreChangedRequestMessage) toAppMessage() (appmessage.Message, error) {
if x == nil {
return nil, errors.Wrapf(errorNil, "NotifyVirtualSelectedParentBlueScoreChangedRequestMessage is nil")
}
return &appmessage.NotifyVirtualSelectedParentBlueScoreChangedRequestMessage{ID: x.Id}, nil
}
func (x *KaspadMessage_NotifyVirtualSelectedParentBlueScoreChangedResponse) toAppMessage() (appmessage.Message, error) { func (x *KaspadMessage_NotifyVirtualSelectedParentBlueScoreChangedResponse) toAppMessage() (appmessage.Message, error) {
if x == nil { if x == nil {
return nil, errors.Wrapf(errorNil, "KaspadMessage_NotifyVirtualSelectedParentBlueScoreChangedResponse is nil") return nil, errors.Wrapf(errorNil, "KaspadMessage_NotifyVirtualSelectedParentBlueScoreChangedResponse is nil")
@ -30,6 +39,7 @@ func (x *KaspadMessage_NotifyVirtualSelectedParentBlueScoreChangedResponse) from
err = &RPCError{Message: message.Error.Message} err = &RPCError{Message: message.Error.Message}
} }
x.NotifyVirtualSelectedParentBlueScoreChangedResponse = &NotifyVirtualSelectedParentBlueScoreChangedResponseMessage{ x.NotifyVirtualSelectedParentBlueScoreChangedResponse = &NotifyVirtualSelectedParentBlueScoreChangedResponseMessage{
Id: message.ID,
Error: err, Error: err,
} }
return nil return nil
@ -45,6 +55,7 @@ func (x *NotifyVirtualSelectedParentBlueScoreChangedResponseMessage) toAppMessag
return nil, err return nil, err
} }
return &appmessage.NotifyVirtualSelectedParentBlueScoreChangedResponseMessage{ return &appmessage.NotifyVirtualSelectedParentBlueScoreChangedResponseMessage{
ID: x.Id,
Error: rpcErr, Error: rpcErr,
}, nil }, nil
} }
@ -58,6 +69,7 @@ func (x *KaspadMessage_VirtualSelectedParentBlueScoreChangedNotification) toAppM
func (x *KaspadMessage_VirtualSelectedParentBlueScoreChangedNotification) fromAppMessage(message *appmessage.VirtualSelectedParentBlueScoreChangedNotificationMessage) error { func (x *KaspadMessage_VirtualSelectedParentBlueScoreChangedNotification) fromAppMessage(message *appmessage.VirtualSelectedParentBlueScoreChangedNotificationMessage) error {
x.VirtualSelectedParentBlueScoreChangedNotification = &VirtualSelectedParentBlueScoreChangedNotificationMessage{ x.VirtualSelectedParentBlueScoreChangedNotification = &VirtualSelectedParentBlueScoreChangedNotificationMessage{
Id: message.ID,
VirtualSelectedParentBlueScore: message.VirtualSelectedParentBlueScore, VirtualSelectedParentBlueScore: message.VirtualSelectedParentBlueScore,
} }
return nil return nil
@ -68,6 +80,7 @@ func (x *VirtualSelectedParentBlueScoreChangedNotificationMessage) toAppMessage(
return nil, errors.Wrapf(errorNil, "VirtualSelectedParentBlueScoreChangedNotificationMessage is nil") return nil, errors.Wrapf(errorNil, "VirtualSelectedParentBlueScoreChangedNotificationMessage is nil")
} }
return &appmessage.VirtualSelectedParentBlueScoreChangedNotificationMessage{ return &appmessage.VirtualSelectedParentBlueScoreChangedNotificationMessage{
ID: x.Id,
VirtualSelectedParentBlueScore: x.VirtualSelectedParentBlueScore, VirtualSelectedParentBlueScore: x.VirtualSelectedParentBlueScore,
}, nil }, nil
} }

View File

@ -9,18 +9,24 @@ func (x *KaspadMessage_NotifyVirtualSelectedParentChainChangedRequest) toAppMess
if x == nil { if x == nil {
return nil, errors.Wrapf(errorNil, "KaspadMessage_NotifyVirtualSelectedParentChainChangedRequest is nil") return nil, errors.Wrapf(errorNil, "KaspadMessage_NotifyVirtualSelectedParentChainChangedRequest is nil")
} }
return &appmessage.NotifyVirtualSelectedParentChainChangedRequestMessage{ return x.NotifyVirtualSelectedParentChainChangedRequest.toAppMessage()
IncludeAcceptedTransactionIDs: x.NotifyVirtualSelectedParentChainChangedRequest.IncludeAcceptedTransactionIds,
}, nil
} }
func (x *KaspadMessage_NotifyVirtualSelectedParentChainChangedRequest) fromAppMessage(appmessage *appmessage.NotifyVirtualSelectedParentChainChangedRequestMessage) error { func (x *KaspadMessage_NotifyVirtualSelectedParentChainChangedRequest) fromAppMessage(message *appmessage.NotifyVirtualSelectedParentChainChangedRequestMessage) error {
x.NotifyVirtualSelectedParentChainChangedRequest = &NotifyVirtualSelectedParentChainChangedRequestMessage{ x.NotifyVirtualSelectedParentChainChangedRequest = &NotifyVirtualSelectedParentChainChangedRequestMessage{
IncludeAcceptedTransactionIds: appmessage.IncludeAcceptedTransactionIDs, Id: message.ID,
IncludeAcceptedTransactionIds: message.IncludeAcceptedTransactionIDs,
} }
return nil return nil
} }
func (x *NotifyVirtualSelectedParentChainChangedRequestMessage) toAppMessage() (appmessage.Message, error) {
if x == nil {
return nil, errors.Wrapf(errorNil, "NotifyVirtualSelectedParentChainChangedRequestMessage is nil")
}
return &appmessage.NotifyVirtualSelectedParentChainChangedRequestMessage{ID: x.Id}, nil
}
func (x *KaspadMessage_NotifyVirtualSelectedParentChainChangedResponse) toAppMessage() (appmessage.Message, error) { func (x *KaspadMessage_NotifyVirtualSelectedParentChainChangedResponse) toAppMessage() (appmessage.Message, error) {
if x == nil { if x == nil {
return nil, errors.Wrapf(errorNil, "KaspadMessage_NotifyVirtualSelectedParentChainChangedResponse is nil") return nil, errors.Wrapf(errorNil, "KaspadMessage_NotifyVirtualSelectedParentChainChangedResponse is nil")
@ -34,6 +40,7 @@ func (x *KaspadMessage_NotifyVirtualSelectedParentChainChangedResponse) fromAppM
err = &RPCError{Message: message.Error.Message} err = &RPCError{Message: message.Error.Message}
} }
x.NotifyVirtualSelectedParentChainChangedResponse = &NotifyVirtualSelectedParentChainChangedResponseMessage{ x.NotifyVirtualSelectedParentChainChangedResponse = &NotifyVirtualSelectedParentChainChangedResponseMessage{
Id: message.ID,
Error: err, Error: err,
} }
return nil return nil
@ -49,6 +56,7 @@ func (x *NotifyVirtualSelectedParentChainChangedResponseMessage) toAppMessage()
return nil, err return nil, err
} }
return &appmessage.NotifyVirtualSelectedParentChainChangedResponseMessage{ return &appmessage.NotifyVirtualSelectedParentChainChangedResponseMessage{
ID: x.Id,
Error: rpcErr, Error: rpcErr,
}, nil }, nil
} }
@ -62,6 +70,7 @@ func (x *KaspadMessage_VirtualSelectedParentChainChangedNotification) toAppMessa
func (x *KaspadMessage_VirtualSelectedParentChainChangedNotification) fromAppMessage(message *appmessage.VirtualSelectedParentChainChangedNotificationMessage) error { func (x *KaspadMessage_VirtualSelectedParentChainChangedNotification) fromAppMessage(message *appmessage.VirtualSelectedParentChainChangedNotificationMessage) error {
x.VirtualSelectedParentChainChangedNotification = &VirtualSelectedParentChainChangedNotificationMessage{ x.VirtualSelectedParentChainChangedNotification = &VirtualSelectedParentChainChangedNotificationMessage{
Id: message.ID,
RemovedChainBlockHashes: message.RemovedChainBlockHashes, RemovedChainBlockHashes: message.RemovedChainBlockHashes,
AddedChainBlockHashes: message.AddedChainBlockHashes, AddedChainBlockHashes: message.AddedChainBlockHashes,
AcceptedTransactionIds: make([]*AcceptedTransactionIds, len(message.AcceptedTransactionIDs)), AcceptedTransactionIds: make([]*AcceptedTransactionIds, len(message.AcceptedTransactionIDs)),
@ -79,6 +88,7 @@ func (x *VirtualSelectedParentChainChangedNotificationMessage) toAppMessage() (a
return nil, errors.Wrapf(errorNil, "VirtualSelectedParentChainChangedNotificationMessage is nil") return nil, errors.Wrapf(errorNil, "VirtualSelectedParentChainChangedNotificationMessage is nil")
} }
message := &appmessage.VirtualSelectedParentChainChangedNotificationMessage{ message := &appmessage.VirtualSelectedParentChainChangedNotificationMessage{
ID: x.Id,
RemovedChainBlockHashes: x.RemovedChainBlockHashes, RemovedChainBlockHashes: x.RemovedChainBlockHashes,
AddedChainBlockHashes: x.AddedChainBlockHashes, AddedChainBlockHashes: x.AddedChainBlockHashes,
AcceptedTransactionIDs: make([]*appmessage.AcceptedTransactionIDs, len(x.AcceptedTransactionIds)), AcceptedTransactionIDs: make([]*appmessage.AcceptedTransactionIDs, len(x.AcceptedTransactionIds)),

View File

@ -14,6 +14,7 @@ func (x *KaspadMessage_StopNotifyingUtxosChangedRequest) toAppMessage() (appmess
func (x *KaspadMessage_StopNotifyingUtxosChangedRequest) fromAppMessage(message *appmessage.StopNotifyingUTXOsChangedRequestMessage) error { func (x *KaspadMessage_StopNotifyingUtxosChangedRequest) fromAppMessage(message *appmessage.StopNotifyingUTXOsChangedRequestMessage) error {
x.StopNotifyingUtxosChangedRequest = &StopNotifyingUtxosChangedRequestMessage{ x.StopNotifyingUtxosChangedRequest = &StopNotifyingUtxosChangedRequestMessage{
Id: message.ID,
Addresses: message.Addresses, Addresses: message.Addresses,
} }
return nil return nil
@ -24,6 +25,7 @@ func (x *StopNotifyingUtxosChangedRequestMessage) toAppMessage() (appmessage.Mes
return nil, errors.Wrapf(errorNil, "StopNotifyingUtxosChangedRequestMessage is nil") return nil, errors.Wrapf(errorNil, "StopNotifyingUtxosChangedRequestMessage is nil")
} }
return &appmessage.StopNotifyingUTXOsChangedRequestMessage{ return &appmessage.StopNotifyingUTXOsChangedRequestMessage{
ID: x.Id,
Addresses: x.Addresses, Addresses: x.Addresses,
}, nil }, nil
} }
@ -41,6 +43,7 @@ func (x *KaspadMessage_StopNotifyingUtxosChangedResponse) fromAppMessage(message
err = &RPCError{Message: message.Error.Message} err = &RPCError{Message: message.Error.Message}
} }
x.StopNotifyingUtxosChangedResponse = &StopNotifyingUtxosChangedResponseMessage{ x.StopNotifyingUtxosChangedResponse = &StopNotifyingUtxosChangedResponseMessage{
Id: message.ID,
Error: err, Error: err,
} }
return nil return nil
@ -56,6 +59,7 @@ func (x *StopNotifyingUtxosChangedResponseMessage) toAppMessage() (appmessage.Me
return nil, err return nil, err
} }
return &appmessage.StopNotifyingUTXOsChangedResponseMessage{ return &appmessage.StopNotifyingUTXOsChangedResponseMessage{
ID: x.Id,
Error: rpcErr, Error: rpcErr,
}, nil }, nil
} }

View File

@ -2,6 +2,7 @@ package rpcclient
import ( import (
"github.com/kaspanet/kaspad/app/appmessage" "github.com/kaspanet/kaspad/app/appmessage"
"github.com/kaspanet/kaspad/app/rpc/rpccontext"
routerpkg "github.com/kaspanet/kaspad/infrastructure/network/netadapter/router" routerpkg "github.com/kaspanet/kaspad/infrastructure/network/netadapter/router"
"github.com/pkg/errors" "github.com/pkg/errors"
) )
@ -9,7 +10,38 @@ import (
// RegisterForBlockAddedNotifications sends an RPC request respective to the function's name and returns the RPC server's response. // RegisterForBlockAddedNotifications sends an RPC request respective to the function's name and returns the RPC server's response.
// Additionally, it starts listening for the appropriate notification using the given handler function // Additionally, it starts listening for the appropriate notification using the given handler function
func (c *RPCClient) RegisterForBlockAddedNotifications(onBlockAdded func(notification *appmessage.BlockAddedNotificationMessage)) error { func (c *RPCClient) RegisterForBlockAddedNotifications(onBlockAdded func(notification *appmessage.BlockAddedNotificationMessage)) error {
err := c.rpcRouter.outgoingRoute().Enqueue(appmessage.NewNotifyBlockAddedRequestMessage()) err := c.rpcRouter.outgoingRoute().Enqueue(appmessage.NewNotifyBlockAddedRequestMessage(rpccontext.DefaultNotificationID))
if err != nil {
return err
}
response, err := c.route(appmessage.CmdNotifyBlockAddedResponseMessage).DequeueWithTimeout(c.timeout)
if err != nil {
return err
}
notifyBlockAddedResponse := response.(*appmessage.NotifyBlockAddedResponseMessage)
if notifyBlockAddedResponse.Error != nil {
return c.convertRPCError(notifyBlockAddedResponse.Error)
}
spawn("RegisterForBlockAddedNotifications", func() {
for {
notification, err := c.route(appmessage.CmdBlockAddedNotificationMessage).Dequeue()
if err != nil {
if errors.Is(err, routerpkg.ErrRouteClosed) {
break
}
panic(err)
}
blockAddedNotification := notification.(*appmessage.BlockAddedNotificationMessage)
onBlockAdded(blockAddedNotification)
}
})
return nil
}
// RegisterForBlockAddedNotificationsWithID does the same as
// RegisterForBlockAddedNotifications, but allows the client to specify an id
func (c *RPCClient) RegisterForBlockAddedNotificationsWithID(onBlockAdded func(notification *appmessage.BlockAddedNotificationMessage), id string) error {
err := c.rpcRouter.outgoingRoute().Enqueue(appmessage.NewNotifyBlockAddedRequestMessage(id))
if err != nil { if err != nil {
return err return err
} }

View File

@ -2,6 +2,7 @@ package rpcclient
import ( import (
"github.com/kaspanet/kaspad/app/appmessage" "github.com/kaspanet/kaspad/app/appmessage"
"github.com/kaspanet/kaspad/app/rpc/rpccontext"
routerpkg "github.com/kaspanet/kaspad/infrastructure/network/netadapter/router" routerpkg "github.com/kaspanet/kaspad/infrastructure/network/netadapter/router"
"github.com/pkg/errors" "github.com/pkg/errors"
) )
@ -12,7 +13,7 @@ func (c *RPCClient) RegisterForVirtualSelectedParentChainChangedNotifications(in
onChainChanged func(notification *appmessage.VirtualSelectedParentChainChangedNotificationMessage)) error { onChainChanged func(notification *appmessage.VirtualSelectedParentChainChangedNotificationMessage)) error {
err := c.rpcRouter.outgoingRoute().Enqueue( err := c.rpcRouter.outgoingRoute().Enqueue(
appmessage.NewNotifyVirtualSelectedParentChainChangedRequestMessage(includeAcceptedTransactionIDs)) appmessage.NewNotifyVirtualSelectedParentChainChangedRequestMessage(includeAcceptedTransactionIDs, rpccontext.DefaultNotificationID))
if err != nil { if err != nil {
return err return err
} }
@ -39,3 +40,37 @@ func (c *RPCClient) RegisterForVirtualSelectedParentChainChangedNotifications(in
}) })
return nil return nil
} }
// RegisterForVirtualSelectedParentChainChangedNotificationsWithID does the same as
// RegisterForVirtualSelectedParentChainChangedNotifications, but allows the client to specify an id
func (c *RPCClient) RegisterForVirtualSelectedParentChainChangedNotificationsWithID(includeAcceptedTransactionIDs bool,
onChainChanged func(notification *appmessage.VirtualSelectedParentChainChangedNotificationMessage), id string) error {
err := c.rpcRouter.outgoingRoute().Enqueue(
appmessage.NewNotifyVirtualSelectedParentChainChangedRequestMessage(includeAcceptedTransactionIDs, id))
if err != nil {
return err
}
response, err := c.route(appmessage.CmdNotifyVirtualSelectedParentChainChangedResponseMessage).DequeueWithTimeout(c.timeout)
if err != nil {
return err
}
notifyChainChangedResponse := response.(*appmessage.NotifyVirtualSelectedParentChainChangedResponseMessage)
if notifyChainChangedResponse.Error != nil {
return c.convertRPCError(notifyChainChangedResponse.Error)
}
spawn("RegisterForVirtualSelectedParentChainChangedNotificationsWithID", func() {
for {
notification, err := c.route(appmessage.CmdVirtualSelectedParentChainChangedNotificationMessage).Dequeue()
if err != nil {
if errors.Is(err, routerpkg.ErrRouteClosed) {
break
}
panic(err)
}
ChainChangedNotification := notification.(*appmessage.VirtualSelectedParentChainChangedNotificationMessage)
onChainChanged(ChainChangedNotification)
}
})
return nil
}

View File

@ -2,6 +2,7 @@ package rpcclient
import ( import (
"github.com/kaspanet/kaspad/app/appmessage" "github.com/kaspanet/kaspad/app/appmessage"
"github.com/kaspanet/kaspad/app/rpc/rpccontext"
routerpkg "github.com/kaspanet/kaspad/infrastructure/network/netadapter/router" routerpkg "github.com/kaspanet/kaspad/infrastructure/network/netadapter/router"
"github.com/pkg/errors" "github.com/pkg/errors"
) )
@ -12,7 +13,7 @@ func (c *RPCClient) RegisterForFinalityConflictsNotifications(
onFinalityConflict func(notification *appmessage.FinalityConflictNotificationMessage), onFinalityConflict func(notification *appmessage.FinalityConflictNotificationMessage),
onFinalityConflictResolved func(notification *appmessage.FinalityConflictResolvedNotificationMessage)) error { onFinalityConflictResolved func(notification *appmessage.FinalityConflictResolvedNotificationMessage)) error {
err := c.rpcRouter.outgoingRoute().Enqueue(appmessage.NewNotifyFinalityConflictsRequestMessage()) err := c.rpcRouter.outgoingRoute().Enqueue(appmessage.NewNotifyFinalityConflictsRequestMessage(rpccontext.DefaultNotificationID))
if err != nil { if err != nil {
return err return err
} }
@ -52,3 +53,50 @@ func (c *RPCClient) RegisterForFinalityConflictsNotifications(
}) })
return nil return nil
} }
// RegisterForFinalityConflictsNotificationsWithID does the same as
// RegisterForFinalityConflictsNotifications, but allows the client to specify an id
func (c *RPCClient) RegisterForFinalityConflictsNotificationsWithID(
onFinalityConflict func(notification *appmessage.FinalityConflictNotificationMessage),
onFinalityConflictResolved func(notification *appmessage.FinalityConflictResolvedNotificationMessage), id string) error {
err := c.rpcRouter.outgoingRoute().Enqueue(appmessage.NewNotifyFinalityConflictsRequestMessage(id))
if err != nil {
return err
}
response, err := c.route(appmessage.CmdNotifyFinalityConflictsResponseMessage).DequeueWithTimeout(c.timeout)
if err != nil {
return err
}
notifyFinalityConflictsResponse := response.(*appmessage.NotifyFinalityConflictsResponseMessage)
if notifyFinalityConflictsResponse.Error != nil {
return c.convertRPCError(notifyFinalityConflictsResponse.Error)
}
spawn("RegisterForFinalityConflictsNotificationsWithID-finalityConflict", func() {
for {
notification, err := c.route(appmessage.CmdFinalityConflictNotificationMessage).Dequeue()
if err != nil {
if errors.Is(err, routerpkg.ErrRouteClosed) {
break
}
panic(err)
}
finalityConflictNotification := notification.(*appmessage.FinalityConflictNotificationMessage)
onFinalityConflict(finalityConflictNotification)
}
})
spawn("RegisterForFinalityConflictsNotificationsWithID-finalityConflictResolved", func() {
for {
notification, err := c.route(appmessage.CmdFinalityConflictResolvedNotificationMessage).Dequeue()
if err != nil {
if errors.Is(err, routerpkg.ErrRouteClosed) {
break
}
panic(err)
}
finalityConflictResolvedNotification := notification.(*appmessage.FinalityConflictResolvedNotificationMessage)
onFinalityConflictResolved(finalityConflictResolvedNotification)
}
})
return nil
}

View File

@ -2,6 +2,7 @@ package rpcclient
import ( import (
"github.com/kaspanet/kaspad/app/appmessage" "github.com/kaspanet/kaspad/app/appmessage"
"github.com/kaspanet/kaspad/app/rpc/rpccontext"
routerpkg "github.com/kaspanet/kaspad/infrastructure/network/netadapter/router" routerpkg "github.com/kaspanet/kaspad/infrastructure/network/netadapter/router"
"github.com/pkg/errors" "github.com/pkg/errors"
) )
@ -9,7 +10,7 @@ import (
// RegisterForNewBlockTemplateNotifications sends an RPC request respective to the function's name and returns the RPC server's response. // RegisterForNewBlockTemplateNotifications sends an RPC request respective to the function's name and returns the RPC server's response.
// Additionally, it starts listening for the appropriate notification using the given handler function // Additionally, it starts listening for the appropriate notification using the given handler function
func (c *RPCClient) RegisterForNewBlockTemplateNotifications(onNewBlockTemplate func(notification *appmessage.NewBlockTemplateNotificationMessage)) error { func (c *RPCClient) RegisterForNewBlockTemplateNotifications(onNewBlockTemplate func(notification *appmessage.NewBlockTemplateNotificationMessage)) error {
err := c.rpcRouter.outgoingRoute().Enqueue(appmessage.NewNotifyNewBlockTemplateRequestMessage()) err := c.rpcRouter.outgoingRoute().Enqueue(appmessage.NewNotifyNewBlockTemplateRequestMessage(rpccontext.DefaultNotificationID))
if err != nil { if err != nil {
return err return err
} }
@ -36,3 +37,34 @@ func (c *RPCClient) RegisterForNewBlockTemplateNotifications(onNewBlockTemplate
}) })
return nil return nil
} }
// RegisterForNewBlockTemplateNotificationsWithID does the same as
// RegisterForNewBlockTemplateNotifications, but allows the client to specify an id
func (c *RPCClient) RegisterForNewBlockTemplateNotificationsWithID(onNewBlockTemplate func(notification *appmessage.NewBlockTemplateNotificationMessage), id string) error {
err := c.rpcRouter.outgoingRoute().Enqueue(appmessage.NewNotifyNewBlockTemplateRequestMessage(id))
if err != nil {
return err
}
response, err := c.route(appmessage.CmdNotifyNewBlockTemplateResponseMessage).DequeueWithTimeout(c.timeout)
if err != nil {
return err
}
notifyNewBlockTemplateResponse := response.(*appmessage.NotifyNewBlockTemplateResponseMessage)
if notifyNewBlockTemplateResponse.Error != nil {
return c.convertRPCError(notifyNewBlockTemplateResponse.Error)
}
spawn("RegisterForNewBlockTemplateNotificationsWithID", func() {
for {
notification, err := c.route(appmessage.CmdNewBlockTemplateNotificationMessage).Dequeue()
if err != nil {
if errors.Is(err, routerpkg.ErrRouteClosed) {
break
}
panic(err)
}
NewBlockTemplateNotification := notification.(*appmessage.NewBlockTemplateNotificationMessage)
onNewBlockTemplate(NewBlockTemplateNotification)
}
})
return nil
}

View File

@ -2,15 +2,16 @@ package rpcclient
import ( import (
"github.com/kaspanet/kaspad/app/appmessage" "github.com/kaspanet/kaspad/app/appmessage"
"github.com/kaspanet/kaspad/app/rpc/rpccontext"
routerpkg "github.com/kaspanet/kaspad/infrastructure/network/netadapter/router" routerpkg "github.com/kaspanet/kaspad/infrastructure/network/netadapter/router"
"github.com/pkg/errors" "github.com/pkg/errors"
) )
// RegisterPruningPointUTXOSetNotifications sends an RPC request respective to the function's name and returns the RPC server's response. // RegisterPruningPointUTXOSetNotifications sends an RPC request respective to the function's name and returns the RPC server's response.
// Additionally, it starts listening for the appropriate notification using the given handler function // Additionally, it starts listening for the appropriate notification using the given handler function
func (c *RPCClient) RegisterPruningPointUTXOSetNotifications(onPruningPointUTXOSetNotifications func()) error { func (c *RPCClient) RegisterPruningPointUTXOSetNotifications(onPruningPointUTXOSetNotifications func(notification *appmessage.PruningPointUTXOSetOverrideNotificationMessage)) error {
err := c.rpcRouter.outgoingRoute().Enqueue(appmessage.NewNotifyPruningPointUTXOSetOverrideRequestMessage()) err := c.rpcRouter.outgoingRoute().Enqueue(appmessage.NewNotifyPruningPointUTXOSetOverrideRequestMessage(rpccontext.DefaultNotificationID))
if err != nil { if err != nil {
return err return err
} }
@ -31,8 +32,8 @@ func (c *RPCClient) RegisterPruningPointUTXOSetNotifications(onPruningPointUTXOS
} }
panic(err) panic(err)
} }
_ = notification.(*appmessage.PruningPointUTXOSetOverrideNotificationMessage) // Sanity check the type newPruningPointUTXOSetOverrideNotification := notification.(*appmessage.PruningPointUTXOSetOverrideNotificationMessage) // Sanity check the type
onPruningPointUTXOSetNotifications() onPruningPointUTXOSetNotifications(newPruningPointUTXOSetOverrideNotification)
} }
}) })
return nil return nil
@ -42,7 +43,58 @@ func (c *RPCClient) RegisterPruningPointUTXOSetNotifications(onPruningPointUTXOS
// Additionally, it stops listening for the appropriate notification using the given handler function // Additionally, it stops listening for the appropriate notification using the given handler function
func (c *RPCClient) UnregisterPruningPointUTXOSetNotifications() error { func (c *RPCClient) UnregisterPruningPointUTXOSetNotifications() error {
err := c.rpcRouter.outgoingRoute().Enqueue(appmessage.NewStopNotifyingPruningPointUTXOSetOverrideRequestMessage()) err := c.rpcRouter.outgoingRoute().Enqueue(appmessage.NewStopNotifyingPruningPointUTXOSetOverrideRequestMessage(rpccontext.DefaultNotificationID))
if err != nil {
return err
}
response, err := c.route(appmessage.CmdStopNotifyingPruningPointUTXOSetOverrideResponseMessage).DequeueWithTimeout(c.timeout)
if err != nil {
return err
}
stopNotifyPruningPointUTXOSetOverrideResponse := response.(*appmessage.StopNotifyingPruningPointUTXOSetOverrideResponseMessage)
if stopNotifyPruningPointUTXOSetOverrideResponse.Error != nil {
return c.convertRPCError(stopNotifyPruningPointUTXOSetOverrideResponse.Error)
}
return nil
}
// RegisterPruningPointUTXOSetNotificationsWithID does the same as
// RegisterPruningPointUTXOSetNotifications, but allows the client to specify an id
func (c *RPCClient) RegisterPruningPointUTXOSetNotificationsWithID(onPruningPointUTXOSetNotifications func(notification *appmessage.PruningPointUTXOSetOverrideNotificationMessage), id string) error {
err := c.rpcRouter.outgoingRoute().Enqueue(appmessage.NewNotifyPruningPointUTXOSetOverrideRequestMessage(id))
if err != nil {
return err
}
response, err := c.route(appmessage.CmdNotifyPruningPointUTXOSetOverrideResponseMessage).DequeueWithTimeout(c.timeout)
if err != nil {
return err
}
notifyPruningPointUTXOSetOverrideResponse := response.(*appmessage.NotifyPruningPointUTXOSetOverrideResponseMessage)
if notifyPruningPointUTXOSetOverrideResponse.Error != nil {
return c.convertRPCError(notifyPruningPointUTXOSetOverrideResponse.Error)
}
spawn("RegisterPruningPointUTXOSetNotificationsWithID", func() {
for {
notification, err := c.route(appmessage.CmdPruningPointUTXOSetOverrideNotificationMessage).Dequeue()
if err != nil {
if errors.Is(err, routerpkg.ErrRouteClosed) {
break
}
panic(err)
}
newPruningPointUTXOSetOverrideNotification := notification.(*appmessage.PruningPointUTXOSetOverrideNotificationMessage) // Sanity check the type
onPruningPointUTXOSetNotifications(newPruningPointUTXOSetOverrideNotification)
}
})
return nil
}
// UnregisterPruningPointUTXOSetNotificationsWithID does the same as
// UnregisterPruningPointUTXOSetNotifications, but allows the client to specify an id
func (c *RPCClient) UnregisterPruningPointUTXOSetNotificationsWithID(id string) error {
err := c.rpcRouter.outgoingRoute().Enqueue(appmessage.NewStopNotifyingPruningPointUTXOSetOverrideRequestMessage(id))
if err != nil { if err != nil {
return err return err
} }

View File

@ -2,6 +2,7 @@ package rpcclient
import ( import (
"github.com/kaspanet/kaspad/app/appmessage" "github.com/kaspanet/kaspad/app/appmessage"
"github.com/kaspanet/kaspad/app/rpc/rpccontext"
routerpkg "github.com/kaspanet/kaspad/infrastructure/network/netadapter/router" routerpkg "github.com/kaspanet/kaspad/infrastructure/network/netadapter/router"
"github.com/pkg/errors" "github.com/pkg/errors"
) )
@ -11,7 +12,7 @@ import (
func (c *RPCClient) RegisterForUTXOsChangedNotifications(addresses []string, func (c *RPCClient) RegisterForUTXOsChangedNotifications(addresses []string,
onUTXOsChanged func(notification *appmessage.UTXOsChangedNotificationMessage)) error { onUTXOsChanged func(notification *appmessage.UTXOsChangedNotificationMessage)) error {
err := c.rpcRouter.outgoingRoute().Enqueue(appmessage.NewNotifyUTXOsChangedRequestMessage(addresses)) err := c.rpcRouter.outgoingRoute().Enqueue(appmessage.NewNotifyUTXOsChangedRequestMessage(addresses, rpccontext.DefaultNotificationID))
if err != nil { if err != nil {
return err return err
} }
@ -38,3 +39,36 @@ func (c *RPCClient) RegisterForUTXOsChangedNotifications(addresses []string,
}) })
return nil return nil
} }
// RegisterForUTXOsChangedNotificationsWithID does the same as
// RegisterForUTXOsChangedNotifications, but allows the client to specify an id
func (c *RPCClient) RegisterForUTXOsChangedNotificationsWithID(addresses []string,
onUTXOsChanged func(notification *appmessage.UTXOsChangedNotificationMessage), id string) error {
err := c.rpcRouter.outgoingRoute().Enqueue(appmessage.NewNotifyUTXOsChangedRequestMessage(addresses, id))
if err != nil {
return err
}
response, err := c.route(appmessage.CmdNotifyUTXOsChangedResponseMessage).DequeueWithTimeout(c.timeout)
if err != nil {
return err
}
notifyUTXOsChangedResponse := response.(*appmessage.NotifyUTXOsChangedResponseMessage)
if notifyUTXOsChangedResponse.Error != nil {
return c.convertRPCError(notifyUTXOsChangedResponse.Error)
}
spawn("RegisterForUTXOsChangedNotificationsWithID", func() {
for {
notification, err := c.route(appmessage.CmdUTXOsChangedNotificationMessage).Dequeue()
if err != nil {
if errors.Is(err, routerpkg.ErrRouteClosed) {
break
}
panic(err)
}
UTXOsChangedNotification := notification.(*appmessage.UTXOsChangedNotificationMessage)
onUTXOsChanged(UTXOsChangedNotification)
}
})
return nil
}

View File

@ -2,6 +2,7 @@ package rpcclient
import ( import (
"github.com/kaspanet/kaspad/app/appmessage" "github.com/kaspanet/kaspad/app/appmessage"
"github.com/kaspanet/kaspad/app/rpc/rpccontext"
routerpkg "github.com/kaspanet/kaspad/infrastructure/network/netadapter/router" routerpkg "github.com/kaspanet/kaspad/infrastructure/network/netadapter/router"
"github.com/pkg/errors" "github.com/pkg/errors"
) )
@ -12,7 +13,7 @@ import (
func (c *RPCClient) RegisterForVirtualDaaScoreChangedNotifications( func (c *RPCClient) RegisterForVirtualDaaScoreChangedNotifications(
onVirtualDaaScoreChanged func(notification *appmessage.VirtualDaaScoreChangedNotificationMessage)) error { onVirtualDaaScoreChanged func(notification *appmessage.VirtualDaaScoreChangedNotificationMessage)) error {
err := c.rpcRouter.outgoingRoute().Enqueue(appmessage.NewNotifyVirtualDaaScoreChangedRequestMessage()) err := c.rpcRouter.outgoingRoute().Enqueue(appmessage.NewNotifyVirtualDaaScoreChangedRequestMessage(rpccontext.DefaultNotificationID))
if err != nil { if err != nil {
return err return err
} }
@ -39,3 +40,36 @@ func (c *RPCClient) RegisterForVirtualDaaScoreChangedNotifications(
}) })
return nil return nil
} }
// RegisterForVirtualDaaScoreChangedNotificationsWithID does the same as
// RegisterForVirtualDaaScoreChangedNotifications, but allows the client to specify an id
func (c *RPCClient) RegisterForVirtualDaaScoreChangedNotificationsWithID(
onVirtualDaaScoreChanged func(notification *appmessage.VirtualDaaScoreChangedNotificationMessage), id string) error {
err := c.rpcRouter.outgoingRoute().Enqueue(appmessage.NewNotifyVirtualDaaScoreChangedRequestMessage(id))
if err != nil {
return err
}
response, err := c.route(appmessage.CmdNotifyVirtualDaaScoreChangedResponseMessage).DequeueWithTimeout(c.timeout)
if err != nil {
return err
}
notifyVirtualDaaScoreChangedResponse := response.(*appmessage.NotifyVirtualDaaScoreChangedResponseMessage)
if notifyVirtualDaaScoreChangedResponse.Error != nil {
return c.convertRPCError(notifyVirtualDaaScoreChangedResponse.Error)
}
spawn("RegisterForVirtualDaaScoreChangedNotificationsWithID", func() {
for {
notification, err := c.route(appmessage.CmdVirtualDaaScoreChangedNotificationMessage).Dequeue()
if err != nil {
if errors.Is(err, routerpkg.ErrRouteClosed) {
break
}
panic(err)
}
VirtualDaaScoreChangedNotification := notification.(*appmessage.VirtualDaaScoreChangedNotificationMessage)
onVirtualDaaScoreChanged(VirtualDaaScoreChangedNotification)
}
})
return nil
}

View File

@ -2,6 +2,7 @@ package rpcclient
import ( import (
"github.com/kaspanet/kaspad/app/appmessage" "github.com/kaspanet/kaspad/app/appmessage"
"github.com/kaspanet/kaspad/app/rpc/rpccontext"
routerpkg "github.com/kaspanet/kaspad/infrastructure/network/netadapter/router" routerpkg "github.com/kaspanet/kaspad/infrastructure/network/netadapter/router"
"github.com/pkg/errors" "github.com/pkg/errors"
) )
@ -12,7 +13,7 @@ import (
func (c *RPCClient) RegisterForVirtualSelectedParentBlueScoreChangedNotifications( func (c *RPCClient) RegisterForVirtualSelectedParentBlueScoreChangedNotifications(
onVirtualSelectedParentBlueScoreChanged func(notification *appmessage.VirtualSelectedParentBlueScoreChangedNotificationMessage)) error { onVirtualSelectedParentBlueScoreChanged func(notification *appmessage.VirtualSelectedParentBlueScoreChangedNotificationMessage)) error {
err := c.rpcRouter.outgoingRoute().Enqueue(appmessage.NewNotifyVirtualSelectedParentBlueScoreChangedRequestMessage()) err := c.rpcRouter.outgoingRoute().Enqueue(appmessage.NewNotifyVirtualSelectedParentBlueScoreChangedRequestMessage(rpccontext.DefaultNotificationID))
if err != nil { if err != nil {
return err return err
} }
@ -39,3 +40,36 @@ func (c *RPCClient) RegisterForVirtualSelectedParentBlueScoreChangedNotification
}) })
return nil return nil
} }
// RegisterForVirtualSelectedParentBlueScoreChangedNotificationsWithID does the same as
// RegisterForVirtualSelectedParentBlueScoreChangedNotifications, but allows the client to specify an id
func (c *RPCClient) RegisterForVirtualSelectedParentBlueScoreChangedNotificationsWithID(
onVirtualSelectedParentBlueScoreChanged func(notification *appmessage.VirtualSelectedParentBlueScoreChangedNotificationMessage), id string) error {
err := c.rpcRouter.outgoingRoute().Enqueue(appmessage.NewNotifyVirtualSelectedParentBlueScoreChangedRequestMessage(id))
if err != nil {
return err
}
response, err := c.route(appmessage.CmdNotifyVirtualSelectedParentBlueScoreChangedResponseMessage).DequeueWithTimeout(c.timeout)
if err != nil {
return err
}
notifyVirtualSelectedParentBlueScoreChangedResponse := response.(*appmessage.NotifyVirtualSelectedParentBlueScoreChangedResponseMessage)
if notifyVirtualSelectedParentBlueScoreChangedResponse.Error != nil {
return c.convertRPCError(notifyVirtualSelectedParentBlueScoreChangedResponse.Error)
}
spawn("RegisterForVirtualSelectedParentBlueScoreChangedNotificationsWithID", func() {
for {
notification, err := c.route(appmessage.CmdVirtualSelectedParentBlueScoreChangedNotificationMessage).Dequeue()
if err != nil {
if errors.Is(err, routerpkg.ErrRouteClosed) {
break
}
panic(err)
}
VirtualSelectedParentBlueScoreChangedNotification := notification.(*appmessage.VirtualSelectedParentBlueScoreChangedNotificationMessage)
onVirtualSelectedParentBlueScoreChanged(VirtualSelectedParentBlueScoreChangedNotification)
}
})
return nil
}

View File

@ -73,7 +73,7 @@ func TestIBD(t *testing.T) {
func TestIBDWithPruning(t *testing.T) { func TestIBDWithPruning(t *testing.T) {
testSync := func(syncer, syncee *appHarness) { testSync := func(syncer, syncee *appHarness) {
utxoSetOverriden := make(chan struct{}) utxoSetOverriden := make(chan struct{})
err := syncee.rpcClient.RegisterPruningPointUTXOSetNotifications(func() { err := syncee.rpcClient.RegisterPruningPointUTXOSetNotifications(func(notification *appmessage.PruningPointUTXOSetOverrideNotificationMessage) {
close(utxoSetOverriden) close(utxoSetOverriden)
}) })
@ -107,7 +107,7 @@ func TestIBDWithPruning(t *testing.T) {
} }
} }
const timeout = 10 * time.Second const timeout = 20 * time.Second
select { select {
case <-utxoSetOverriden: case <-utxoSetOverriden:
case <-time.After(timeout): case <-time.After(timeout):

View File

@ -12,3 +12,286 @@ func setOnBlockAddedHandler(t *testing.T, harness *appHarness, handler func(noti
t.Fatalf("Error from RegisterForBlockAddedNotifications: %s", err) t.Fatalf("Error from RegisterForBlockAddedNotifications: %s", err)
} }
} }
func TestNotificationIDs(t *testing.T) {
kaspad1, kaspad2, kaspad3, teardown := standardSetupWithUtxoindex(t)
defer teardown()
ID1 := "kaspad1"
ID2 := "kaspad2"
ID3 := "kaspad3"
err := kaspad1.rpcClient.RegisterForBlockAddedNotificationsWithID(
func(notification *appmessage.BlockAddedNotificationMessage) {
checkIDs(t, notification.ID, ID1)
},
ID1,
)
if err != nil {
t.Fatalf("Failed to register with RegisterForBlockAddedNotificationsWithID: %s", err)
}
err = kaspad2.rpcClient.RegisterForBlockAddedNotificationsWithID(
func(notification *appmessage.BlockAddedNotificationMessage) {
checkIDs(t, notification.ID, ID2)
},
ID2,
)
if err != nil {
t.Fatalf("Failed to register with RegisterForBlockAddedNotificationsWithID: %s", err)
}
err = kaspad3.rpcClient.RegisterForBlockAddedNotificationsWithID(
func(notification *appmessage.BlockAddedNotificationMessage) {
checkIDs(t, notification.ID, ID3)
},
ID3,
)
if err != nil {
t.Fatalf("Failed to register with RegisterForBlockAddedNotificationsWithID: %s", err)
}
err = kaspad1.rpcClient.RegisterForVirtualSelectedParentBlueScoreChangedNotificationsWithID(
func(notification *appmessage.VirtualSelectedParentBlueScoreChangedNotificationMessage) {
checkIDs(t, notification.ID, ID1)
},
ID1,
)
if err != nil {
t.Fatalf("Failed to register with RegisterForVirtualSelectedParentBlueScoreChangedNotificationsWithID: %s", err)
}
err = kaspad2.rpcClient.RegisterForVirtualSelectedParentBlueScoreChangedNotificationsWithID(
func(notification *appmessage.VirtualSelectedParentBlueScoreChangedNotificationMessage) {
checkIDs(t, notification.ID, ID2)
},
ID2,
)
if err != nil {
t.Fatalf("Failed to register with RegisterForVirtualSelectedParentBlueScoreChangedNotificationsWithID: %s", err)
}
err = kaspad3.rpcClient.RegisterForVirtualSelectedParentBlueScoreChangedNotificationsWithID(
func(notification *appmessage.VirtualSelectedParentBlueScoreChangedNotificationMessage) {
checkIDs(t, notification.ID, ID3)
},
ID3,
)
if err != nil {
t.Fatalf("Failed to register with RegisterForUTXOsChangedNotificationsWithID: %s", err)
}
err = kaspad1.rpcClient.RegisterForUTXOsChangedNotificationsWithID(
[]string{kaspad1.miningAddress, kaspad2.miningAddress, kaspad3.miningAddress},
func(notification *appmessage.UTXOsChangedNotificationMessage) {
checkIDs(t, notification.ID, ID1)
},
ID1,
)
if err != nil {
t.Fatalf("Failed to register with RegisterForUTXOsChangedNotificationsWithID: %s", err)
}
err = kaspad2.rpcClient.RegisterForUTXOsChangedNotificationsWithID(
[]string{kaspad1.miningAddress, kaspad2.miningAddress, kaspad3.miningAddress},
func(notification *appmessage.UTXOsChangedNotificationMessage) {
checkIDs(t, notification.ID, ID2)
},
ID2,
)
if err != nil {
t.Fatalf("Failed to register with RegisterForUTXOsChangedNotificationsWithID: %s", err)
}
err = kaspad3.rpcClient.RegisterForUTXOsChangedNotificationsWithID(
[]string{kaspad1.miningAddress, kaspad2.miningAddress, kaspad3.miningAddress},
func(notification *appmessage.UTXOsChangedNotificationMessage) {
checkIDs(t, notification.ID, ID3)
},
ID3,
)
if err != nil {
t.Fatalf("Failed to register with RegisterForUTXOsChangedNotificationsWithID: %s", err)
}
err = kaspad1.rpcClient.RegisterForNewBlockTemplateNotificationsWithID(
func(notification *appmessage.NewBlockTemplateNotificationMessage) {
checkIDs(t, notification.ID, ID1)
},
ID1,
)
if err != nil {
t.Fatalf("Failed to register with RegisterForNewBlockTemplateNotificationsWithID: %s", err)
}
err = kaspad2.rpcClient.RegisterForNewBlockTemplateNotificationsWithID(
func(notification *appmessage.NewBlockTemplateNotificationMessage) {
checkIDs(t, notification.ID, ID2)
},
ID2,
)
if err != nil {
t.Fatalf("Failed to register with RegisterForNewBlockTemplateNotificationsWithID: %s", err)
}
err = kaspad3.rpcClient.RegisterForNewBlockTemplateNotificationsWithID(
func(notification *appmessage.NewBlockTemplateNotificationMessage) {
checkIDs(t, notification.ID, ID3)
},
ID3,
)
if err != nil {
t.Fatalf("Failed to register with RegisterForNewBlockTemplateNotificationsWithID: %s", err)
}
err = kaspad1.rpcClient.RegisterForVirtualDaaScoreChangedNotificationsWithID(
func(notification *appmessage.VirtualDaaScoreChangedNotificationMessage) {
checkIDs(t, notification.ID, ID1)
},
ID1,
)
if err != nil {
t.Fatalf("Failed to register with RegisterForVirtualDaaScoreChangedNotificationsWithID: %s", err)
}
err = kaspad2.rpcClient.RegisterForVirtualDaaScoreChangedNotificationsWithID(
func(notification *appmessage.VirtualDaaScoreChangedNotificationMessage) {
checkIDs(t, notification.ID, ID2)
},
ID2,
)
if err != nil {
t.Fatalf("Failed to register with RegisterForVirtualDaaScoreChangedNotificationsWithID: %s", err)
}
err = kaspad3.rpcClient.RegisterForVirtualDaaScoreChangedNotificationsWithID(
func(notification *appmessage.VirtualDaaScoreChangedNotificationMessage) {
checkIDs(t, notification.ID, ID3)
},
ID3,
)
if err != nil {
t.Fatalf("Failed to register with RegisterForVirtualDaaScoreChangedNotificationsWithID: %s", err)
}
err = kaspad1.rpcClient.RegisterForVirtualSelectedParentChainChangedNotificationsWithID(
false,
func(notification *appmessage.VirtualSelectedParentChainChangedNotificationMessage) {
checkIDs(t, notification.ID, ID1)
},
ID1,
)
if err != nil {
t.Fatalf("Failed to register with RegisterForVirtualSelectedParentChainChangedNotificationsWithID: %s", err)
}
err = kaspad2.rpcClient.RegisterForVirtualSelectedParentChainChangedNotificationsWithID(
false,
func(notification *appmessage.VirtualSelectedParentChainChangedNotificationMessage) {
checkIDs(t, notification.ID, ID2)
},
ID2,
)
if err != nil {
t.Fatalf("Failed to register with RegisterForVirtualSelectedParentChainChangedNotificationsWithID: %s", err)
}
err = kaspad3.rpcClient.RegisterForVirtualSelectedParentChainChangedNotificationsWithID(
false,
func(notification *appmessage.VirtualSelectedParentChainChangedNotificationMessage) {
checkIDs(t, notification.ID, ID3)
},
ID3,
)
if err != nil {
t.Fatalf("Failed to register with RegisterForVirtualSelectedParentChainChangedNotificationsWithID: %s", err)
}
err = kaspad1.rpcClient.RegisterForFinalityConflictsNotificationsWithID(
func(notification *appmessage.FinalityConflictNotificationMessage) {
checkIDs(t, notification.ID, ID1)
},
func(notification *appmessage.FinalityConflictResolvedNotificationMessage) {
checkIDs(t, notification.ID, ID1)
},
ID1,
)
if err != nil {
t.Fatalf("Failed to register with RegisterForFinalityConflictsNotificationsWithID: %s", err)
}
err = kaspad2.rpcClient.RegisterForFinalityConflictsNotificationsWithID(
func(notification *appmessage.FinalityConflictNotificationMessage) {
checkIDs(t, notification.ID, ID2)
},
func(notification *appmessage.FinalityConflictResolvedNotificationMessage) {
checkIDs(t, notification.ID, ID1)
},
ID2,
)
if err != nil {
t.Fatalf("Failed to register with RegisterForFinalityConflictsNotificationsWithID: %s", err)
}
err = kaspad3.rpcClient.RegisterForFinalityConflictsNotificationsWithID(
func(notification *appmessage.FinalityConflictNotificationMessage) {
checkIDs(t, notification.ID, ID3)
},
func(notification *appmessage.FinalityConflictResolvedNotificationMessage) {
checkIDs(t, notification.ID, ID1)
},
ID3,
)
if err != nil {
t.Fatalf("Failed to register with RegisterForFinalityConflictsNotificationsWithID: %s", err)
}
err = kaspad1.rpcClient.RegisterPruningPointUTXOSetNotificationsWithID(
func(notification *appmessage.PruningPointUTXOSetOverrideNotificationMessage) {
checkIDs(t, notification.ID, ID1)
},
ID1,
)
if err != nil {
t.Fatalf("Failed to register with RegisterPruningPointUTXOSetNotificationsWithID: %s", err)
}
err = kaspad2.rpcClient.RegisterPruningPointUTXOSetNotificationsWithID(
func(notification *appmessage.PruningPointUTXOSetOverrideNotificationMessage) {
checkIDs(t, notification.ID, ID2)
},
ID2,
)
if err != nil {
t.Fatalf("Failed to register with RegisterPruningPointUTXOSetNotificationsWithID: %s", err)
}
err = kaspad3.rpcClient.RegisterPruningPointUTXOSetNotificationsWithID(
func(notification *appmessage.PruningPointUTXOSetOverrideNotificationMessage) {
checkIDs(t, notification.ID, ID3)
},
ID3,
)
if err != nil {
t.Fatalf("Failed to register with RegisterPruningPointUTXOSetNotificationsWithID: %s", err)
}
const approxBlockAmountToMine = 100
for i := 0; i < approxBlockAmountToMine/3; i++ {
mineNextBlock(t, kaspad1)
mineNextBlock(t, kaspad2)
mineNextBlock(t, kaspad3)
}
}
func checkIDs(t *testing.T, notificationID string, expectedID string) {
if expectedID == "" {
t.Fatalf("the kaspad with assigned id %s is using the default id %s - cannot test id assignment!", expectedID, "")
}
if notificationID != expectedID {
t.Fatalf("the kaspad with assigned id %s got a notification with id %s", expectedID, notificationID)
}
}

View File

@ -100,6 +100,33 @@ func standardSetup(t *testing.T) (appHarness1, appHarness2, appHarness3 *appHarn
return harnesses[0], harnesses[1], harnesses[2], teardown return harnesses[0], harnesses[1], harnesses[2], teardown
} }
func standardSetupWithUtxoindex(t *testing.T) (appHarness1, appHarness2, appHarness3 *appHarness, teardownFunc func()) {
harnesses, teardown := setupHarnesses(t, []*harnessParams{
{
p2pAddress: p2pAddress1,
rpcAddress: rpcAddress1,
miningAddress: miningAddress1,
miningAddressPrivateKey: miningAddress1PrivateKey,
utxoIndex: true,
},
{
p2pAddress: p2pAddress2,
rpcAddress: rpcAddress2,
miningAddress: miningAddress2,
miningAddressPrivateKey: miningAddress2PrivateKey,
utxoIndex: true,
}, {
p2pAddress: p2pAddress3,
rpcAddress: rpcAddress3,
miningAddress: miningAddress3,
miningAddressPrivateKey: miningAddress3PrivateKey,
utxoIndex: true,
},
})
return harnesses[0], harnesses[1], harnesses[2], teardown
}
func setRPCClient(t *testing.T, harness *appHarness) { func setRPCClient(t *testing.T, harness *appHarness) {
var err error var err error
harness.rpcClient, err = newTestRPCClient(harness.rpcAddress) harness.rpcClient, err = newTestRPCClient(harness.rpcAddress)