fix ctx done check

This commit is contained in:
Sina Mahmoodi 2025-05-01 16:36:17 +02:00
parent 91923a6bc4
commit 4792f0a3ba

View file

@ -308,11 +308,14 @@ func (indexer *txIndexer) txIndexProgress(ctx context.Context) (TxIndexProgress,
ch := make(chan TxIndexProgress, 1) ch := make(chan TxIndexProgress, 1)
select { select {
case indexer.progress <- ch: case indexer.progress <- ch:
return <-ch, nil select {
case prog := <-ch:
return prog, nil
case <-ctx.Done():
return TxIndexProgress{}, ctx.Err()
}
case <-indexer.closed: case <-indexer.closed:
return TxIndexProgress{}, errors.New("indexer is closed") return TxIndexProgress{}, errors.New("indexer is closed")
case <-ctx.Done():
return TxIndexProgress{}, ctx.Err()
} }
} }