From 3666ae7ad27087dbe46cc568ff0464565caf3a20 Mon Sep 17 00:00:00 2001 From: Pavel Karpy Date: Thu, 21 Oct 2021 18:09:26 +0300 Subject: [PATCH] [#971] morph/subscriber: Adapt extended notification structure Signed-off-by: Pavel Karpy --- pkg/morph/event/listener.go | 5 ++--- pkg/morph/subscriber/subscriber.go | 11 +++++------ 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/pkg/morph/event/listener.go b/pkg/morph/event/listener.go index 47a2297c..dfa65e2f 100644 --- a/pkg/morph/event/listener.go +++ b/pkg/morph/event/listener.go @@ -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()), ) diff --git a/pkg/morph/subscriber/subscriber.go b/pkg/morph/subscriber/subscriber.go index d8c94b8d..4c394c49 100644 --- a/pkg/morph/subscriber/subscriber.go +++ b/pkg/morph/subscriber/subscriber.go @@ -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 <- ¬ifyEvent.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),