From 4792f0a3ba2c3d8e5d6a5ce778cd6eaf350c96e4 Mon Sep 17 00:00:00 2001 From: Sina Mahmoodi Date: Thu, 1 May 2025 16:36:17 +0200 Subject: [PATCH] fix ctx done check --- core/txindexer.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/core/txindexer.go b/core/txindexer.go index 7325095da6..6c5361f519 100644 --- a/core/txindexer.go +++ b/core/txindexer.go @@ -308,11 +308,14 @@ func (indexer *txIndexer) txIndexProgress(ctx context.Context) (TxIndexProgress, ch := make(chan TxIndexProgress, 1) select { case indexer.progress <- ch: - return <-ch, nil + select { + case prog := <-ch: + return prog, nil + case <-ctx.Done(): + return TxIndexProgress{}, ctx.Err() + } case <-indexer.closed: return TxIndexProgress{}, errors.New("indexer is closed") - case <-ctx.Done(): - return TxIndexProgress{}, ctx.Err() } }