[#324] morph/subscriber: Make block channel in constructor

Replace block channel's initialization from BlockNotifications method body
to Subscriber's constructor in order to prevent potential writing to nil
channel.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2021-01-25 14:53:12 +03:00 committed by Alex Vanin
parent d01b4e1a2d
commit 96febdb6a5

View file

@ -112,8 +112,6 @@ func (s *subscriber) BlockNotifications() (<-chan *block.Block, error) {
return nil, errors.Wrap(err, "could not subscribe for new block events")
}
s.blockChan = make(chan *block.Block)
return s.blockChan, nil
}
@ -179,6 +177,7 @@ func New(ctx context.Context, p *Params) (Subscriber, error) {
client: wsClient,
notify: make(chan *state.NotificationEvent),
notifyIDs: make(map[util.Uint160]string),
blockChan: make(chan *block.Block),
}
// Worker listens all events from neo-go websocket and puts them