From 49a156798e91c3d8e7a6bdf7c7752a6c1e5c6fbb Mon Sep 17 00:00:00 2001 From: Artem Date: Fri, 29 Apr 2022 15:57:24 +0300 Subject: [PATCH] Fix: node stucking rule --- cmd/indexer/indexer/boost.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cmd/indexer/indexer/boost.go b/cmd/indexer/indexer/boost.go index 19d15b13a..ba45f84f0 100644 --- a/cmd/indexer/indexer/boost.go +++ b/cmd/indexer/indexer/boost.go @@ -201,10 +201,8 @@ func (bi *BoostIndexer) indexBlock(ctx context.Context, wg *sync.WaitGroup) { case <-ticker.C: if block, ok := bi.blocks[bi.state.Level+1]; ok { if bi.state.Level > 0 && block.Header.Predecessor != bi.state.Hash { - if !time.Now().Add(time.Duration(-5) * time.Minute).After(block.Header.Timestamp) { // Check that node is out of sync - if err := bi.Rollback(ctx); err != nil { - logger.Error().Err(err).Msg("Rollback") - } + if err := bi.Rollback(ctx); err != nil { + logger.Error().Err(err).Msg("Rollback") } } else { if err := bi.handleBlock(ctx, block); err != nil { @@ -333,6 +331,10 @@ func (bi *BoostIndexer) process(ctx context.Context) error { logger.Info().Str("network", bi.Network.String()).Msgf("Current node state: %7d", head.Level) logger.Info().Str("network", bi.Network.String()).Msgf("Current indexer state: %7d", bi.state.Level) + if !time.Now().Add(time.Duration(-5) * time.Minute).After(head.Timestamp) { + return errors.Errorf("node is stucking...") + } + if head.Level > bi.state.Level { if err := bi.Index(ctx, head); err != nil { if errors.Is(err, errBcdQuit) {