[#971] morph/event: Change notification parser's signature

Parsers should have original notification
structure to be able to construct internal
event structure that contains necessary
for unique nonce calculation information.
So notification parsers take raw notification
structure instead of slice of stack items.

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
Pavel Karpy 2021-10-22 13:06:08 +03:00 committed by Alex Vanin
parent 3666ae7ad2
commit c167ae26f9
35 changed files with 365 additions and 203 deletions

View file

@ -3,8 +3,9 @@ package container
import (
"fmt"
"github.com/nspcc-dev/neo-go/pkg/rpc/response/result/subscriptions"
"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"
)
@ -65,12 +66,17 @@ func (x PutNamed) Zone() string {
}
// ParsePut from notification into container event structure.
func ParsePut(params []stackitem.Item) (event.Event, error) {
func ParsePut(e *subscriptions.NotificationEvent) (event.Event, error) {
var (
ev Put
err error
)
params, err := event.ParseStackArray(e)
if err != nil {
return nil, fmt.Errorf("could not parse stack items from notify event: %w", err)
}
if ln := len(params); ln != expectedItemNumPut {
return nil, event.WrongNumberOfParameters(expectedItemNumPut, ln)
}