Skip to content

Commit

Permalink
[blockdao] Fix program unstopable when blockdao is checking indexer (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
envestcc authored Apr 7, 2024
1 parent 40ee548 commit 3b9e91f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions blockchain/blockdao/blockindexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ func (bic *BlockIndexerChecker) CheckIndexer(ctx context.Context, indexer BlockI
}
}
for i := startHeight; i <= targetHeight; i++ {
// ternimate if context is done
if err := ctx.Err(); err != nil {
return errors.Wrap(err, "terminate the indexer checking")
}
blk, err := bic.dao.GetBlockByHeight(i)
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion server/itx/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func newServer(cfg config.Config, testing bool) (*Server, error) {

// Start starts the server
func (s *Server) Start(ctx context.Context) error {
cctx, cancel := context.WithCancel(context.Background())
cctx, cancel := context.WithCancel(ctx)
s.subModuleCancel = cancel
for id, cs := range s.chainservices {
if err := cs.Start(cctx); err != nil {
Expand Down

0 comments on commit 3b9e91f

Please sign in to comment.