[#971] morph/subscriber: Adapt extended notification structure

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
remotes/fyrchik/neofs-adm-update
Pavel Karpy 2021-10-21 18:09:26 +03:00 committed by Alex Vanin
parent c9f2804885
commit 3666ae7ad2
2 changed files with 7 additions and 9 deletions

View File

@ -7,7 +7,6 @@ import (
"sync"
"github.com/nspcc-dev/neo-go/pkg/core/block"
"github.com/nspcc-dev/neo-go/pkg/core/state"
"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"
@ -185,7 +184,7 @@ func (l *listener) listen(ctx context.Context, intError chan<- error) error {
return nil
}
func (l listener) listenLoop(ctx context.Context, chEvent <-chan *state.NotificationEvent, intErr chan<- error) {
func (l listener) listenLoop(ctx context.Context, chEvent <-chan *subscriptions.NotificationEvent, intErr chan<- error) {
var (
blockChan <-chan *block.Block
@ -281,7 +280,7 @@ loop:
}
}
func (l listener) parseAndHandleNotification(notifyEvent *state.NotificationEvent) {
func (l listener) parseAndHandleNotification(notifyEvent *subscriptions.NotificationEvent) {
log := l.log.With(
zap.String("script hash LE", notifyEvent.ScriptHash.StringLE()),
)

View File

@ -8,7 +8,6 @@ import (
"time"
"github.com/nspcc-dev/neo-go/pkg/core/block"
"github.com/nspcc-dev/neo-go/pkg/core/state"
"github.com/nspcc-dev/neo-go/pkg/rpc/client"
"github.com/nspcc-dev/neo-go/pkg/rpc/response"
"github.com/nspcc-dev/neo-go/pkg/rpc/response/result/subscriptions"
@ -19,7 +18,7 @@ import (
type (
// Subscriber is an interface of the NotificationEvent listener.
Subscriber interface {
SubscribeForNotification(...util.Uint160) (<-chan *state.NotificationEvent, error)
SubscribeForNotification(...util.Uint160) (<-chan *subscriptions.NotificationEvent, error)
UnsubscribeForNotification()
BlockNotifications() (<-chan *block.Block, error)
SubscribeForNotaryRequests(mainTXSigner util.Uint160) (<-chan *subscriptions.NotaryRequestEvent, error)
@ -31,7 +30,7 @@ type (
log *zap.Logger
client *client.WSClient
notifyChan chan *state.NotificationEvent
notifyChan chan *subscriptions.NotificationEvent
notifyIDs map[util.Uint160]string
blockChan chan *block.Block
@ -54,7 +53,7 @@ var (
errNilLogger = errors.New("chain/subscriber: logger was not provided to the constructor")
)
func (s *subscriber) SubscribeForNotification(contracts ...util.Uint160) (<-chan *state.NotificationEvent, error) {
func (s *subscriber) SubscribeForNotification(contracts ...util.Uint160) (<-chan *subscriptions.NotificationEvent, error) {
s.Lock()
defer s.Unlock()
@ -150,7 +149,7 @@ func (s *subscriber) routeNotifications(ctx context.Context) {
continue
}
s.notifyChan <- &notifyEvent.NotificationEvent
s.notifyChan <- notifyEvent
case response.BlockEventID:
b, ok := notification.Value.(*block.Block)
if !ok {
@ -213,7 +212,7 @@ func New(ctx context.Context, p *Params) (Subscriber, error) {
RWMutex: new(sync.RWMutex),
log: p.Log,
client: wsClient,
notifyChan: make(chan *state.NotificationEvent),
notifyChan: make(chan *subscriptions.NotificationEvent),
notifyIDs: make(map[util.Uint160]string),
blockChan: make(chan *block.Block),
notaryChan: make(chan *subscriptions.NotaryRequestEvent),