[#846] morph/event: Add notary request to addPeer event

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
Pavel Karpy 2021-09-23 19:12:49 +03:00 committed by Alex Vanin
parent 5e74830c38
commit 3a8f0edac1
2 changed files with 13 additions and 0 deletions

View file

@ -3,6 +3,7 @@ package netmap
import ( import (
"fmt" "fmt"
"github.com/nspcc-dev/neo-go/pkg/network/payload"
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem" "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/client"
"github.com/nspcc-dev/neofs-node/pkg/morph/event" "github.com/nspcc-dev/neofs-node/pkg/morph/event"
@ -10,6 +11,10 @@ import (
type AddPeer struct { type AddPeer struct {
node []byte node []byte
// For notary notifications only.
// Contains raw transactions of notary request.
notaryRequest *payload.P2PNotaryRequest
} }
// MorphEvent implements Neo:Morph Event interface. // MorphEvent implements Neo:Morph Event interface.
@ -19,6 +24,12 @@ func (s AddPeer) Node() []byte {
return s.node 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 const expectedItemNumAddPeer = 1
func ParseAddPeer(prms []stackitem.Item) (event.Event, error) { func ParseAddPeer(prms []stackitem.Item) (event.Event, error) {

View file

@ -43,5 +43,7 @@ func ParseAddPeerNotary(ne event.NotaryEvent) (event.Event, error) {
} }
} }
ev.notaryRequest = ne.Raw()
return ev, nil return ev, nil
} }