[#833] morph/subscriber: Change value cast for NotificationEventID

`WSClient` of Neo Go v0.97.3 sets value of notification with
`NotificationEventID` to `subscriptions.NotificationEvent` type which wraps
previously used `state.NotificationEvent`.

Change type cast and pull `state.NotificationEvent` structure from new type.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2021-10-14 12:39:21 +03:00 committed by Alex Vanin
parent e5e5395830
commit 8efeba8010

View file

@ -142,17 +142,21 @@ func (s *subscriber) routeNotifications(ctx context.Context) {
switch notification.Type {
case response.NotificationEventID:
notification, ok := notification.Value.(*state.NotificationEvent)
notifyEvent, ok := notification.Value.(*subscriptions.NotificationEvent)
if !ok {
s.log.Error("can't cast notify event value to the notify struct")
s.log.Error("can't cast notify event value to the notify struct",
zap.String("received type", fmt.Sprintf("%T", notification.Value)),
)
continue
}
s.notifyChan <- notification
s.notifyChan <- &notifyEvent.NotificationEvent
case response.BlockEventID:
b, ok := notification.Value.(*block.Block)
if !ok {
s.log.Error("can't cast block event value to block")
s.log.Error("can't cast block event value to block",
zap.String("received type", fmt.Sprintf("%T", notification.Value)),
)
continue
}
@ -160,7 +164,9 @@ func (s *subscriber) routeNotifications(ctx context.Context) {
case response.NotaryRequestEventID:
notaryRequest, ok := notification.Value.(*subscriptions.NotaryRequestEvent)
if !ok {
s.log.Error("can't cast notify event value to the notary request struct")
s.log.Error("can't cast notify event value to the notary request struct",
zap.String("received type", fmt.Sprintf("%T", notification.Value)),
)
continue
}