[#324] ir: Register block handler before starting the listening routine

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2021-01-25 16:47:01 +03:00 committed by Alex Vanin
parent 44c899b560
commit abc7885056

View file

@ -118,9 +118,6 @@ func (s *Server) Start(ctx context.Context, intError chan<- error) error {
}
}()
go s.morphListener.ListenWithError(ctx, morphErr) // listen for neo:morph events
go s.mainnetListener.ListenWithError(ctx, mainnnetErr) // listen for neo:mainnet events
s.morphListener.RegisterBlockHandler(func(b *block.Block) {
s.log.Debug("new block",
zap.Uint32("index", b.Index),
@ -129,6 +126,9 @@ func (s *Server) Start(ctx context.Context, intError chan<- error) error {
s.tickTimers()
})
go s.morphListener.ListenWithError(ctx, morphErr) // listen for neo:morph events
go s.mainnetListener.ListenWithError(ctx, mainnnetErr) // listen for neo:mainnet events
if err := s.startBlockTimers(); err != nil {
return errors.Wrap(err, "could not start block timers")
}