[#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,6 +3,8 @@ package container
import (
"fmt"
"github.com/nspcc-dev/neo-go/pkg/rpc/response/result/subscriptions"
"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"
@ -33,7 +35,12 @@ func (s StartEstimation) Epoch() uint64 { return s.epoch }
func (s StopEstimation) Epoch() uint64 { return s.epoch }
// ParseStartEstimation from notification into container event structure.
func ParseStartEstimation(params []stackitem.Item) (event.Event, error) {
func ParseStartEstimation(e *subscriptions.NotificationEvent) (event.Event, error) {
params, err := event.ParseStackArray(e)
if err != nil {
return nil, fmt.Errorf("could not parse stack items from notify event: %w", err)
}
epoch, err := parseEstimation(params)
if err != nil {
return nil, err
@ -43,7 +50,12 @@ func ParseStartEstimation(params []stackitem.Item) (event.Event, error) {
}
// ParseStopEstimation from notification into container event structure.
func ParseStopEstimation(params []stackitem.Item) (event.Event, error) {
func ParseStopEstimation(e *subscriptions.NotificationEvent) (event.Event, error) {
params, err := event.ParseStackArray(e)
if err != nil {
return nil, fmt.Errorf("could not parse stack items from notify event: %w", err)
}
epoch, err := parseEstimation(params)
if err != nil {
return nil, err