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

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
remotes/fyrchik/meta-pebble
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 (
"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) {

View File

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