[#971] *: Add notification TX hash to neofs/netmap morph client calls

Add hash of the TX that generated notification
to neofs/netmap event structures. Adapt all
neofs/netmap wrapper calls to new structures.

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
Pavel Karpy 2021-11-10 14:05:51 +03:00 committed by Alex Vanin
parent c25f5a86ae
commit bad739258e
19 changed files with 220 additions and 60 deletions

View file

@ -4,6 +4,7 @@ import (
"fmt"
"github.com/nspcc-dev/neo-go/pkg/rpc/response/result/subscriptions"
"github.com/nspcc-dev/neo-go/pkg/util"
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
)
@ -11,6 +12,11 @@ import (
// NewEpoch is a new epoch Neo:Morph event.
type NewEpoch struct {
num uint64
// txHash is used in notary environmental
// for calculating unique but same for
// all notification receivers values.
txHash util.Uint256
}
// MorphEvent implements Neo:Morph Event interface.
@ -21,6 +27,12 @@ func (s NewEpoch) EpochNumber() uint64 {
return s.num
}
// TxHash returns hash of the TX with new epoch
// notification.
func (s NewEpoch) TxHash() util.Uint256 {
return s.txHash
}
// ParseNewEpoch is a parser of new epoch notification event.
//
// Result is type of NewEpoch.
@ -40,6 +52,7 @@ func ParseNewEpoch(e *subscriptions.NotificationEvent) (event.Event, error) {
}
return NewEpoch{
num: uint64(prmEpochNum),
num: uint64(prmEpochNum),
txHash: e.Container,
}, nil
}