From 3a8f0edac13c49fcad590b454c679347fae79bca Mon Sep 17 00:00:00 2001 From: Pavel Karpy Date: Thu, 23 Sep 2021 19:12:49 +0300 Subject: [PATCH] [#846] morph/event: Add notary request to `addPeer` event Signed-off-by: Pavel Karpy --- pkg/morph/event/netmap/add_peer.go | 11 +++++++++++ pkg/morph/event/netmap/add_peer_notary.go | 2 ++ 2 files changed, 13 insertions(+) diff --git a/pkg/morph/event/netmap/add_peer.go b/pkg/morph/event/netmap/add_peer.go index e04a8979..1d013b34 100644 --- a/pkg/morph/event/netmap/add_peer.go +++ b/pkg/morph/event/netmap/add_peer.go @@ -3,6 +3,7 @@ package netmap import ( "fmt" + "github.com/nspcc-dev/neo-go/pkg/network/payload" "github.com/nspcc-dev/neo-go/pkg/vm/stackitem" "github.com/nspcc-dev/neofs-node/pkg/morph/client" "github.com/nspcc-dev/neofs-node/pkg/morph/event" @@ -10,6 +11,10 @@ import ( type AddPeer struct { node []byte + + // For notary notifications only. + // Contains raw transactions of notary request. + notaryRequest *payload.P2PNotaryRequest } // MorphEvent implements Neo:Morph Event interface. @@ -19,6 +24,12 @@ func (s AddPeer) Node() []byte { return s.node } +// NotaryRequest returns raw notary request if notification +// was received via notary service. Otherwise, returns nil. +func (s AddPeer) NotaryRequest() *payload.P2PNotaryRequest { + return s.notaryRequest +} + const expectedItemNumAddPeer = 1 func ParseAddPeer(prms []stackitem.Item) (event.Event, error) { diff --git a/pkg/morph/event/netmap/add_peer_notary.go b/pkg/morph/event/netmap/add_peer_notary.go index cdc6961a..d957b0a1 100644 --- a/pkg/morph/event/netmap/add_peer_notary.go +++ b/pkg/morph/event/netmap/add_peer_notary.go @@ -43,5 +43,7 @@ func ParseAddPeerNotary(ne event.NotaryEvent) (event.Event, error) { } } + ev.notaryRequest = ne.Raw() + return ev, nil }