mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 06:36:43 +00:00
fix ctx done check
This commit is contained in:
parent
91923a6bc4
commit
4792f0a3ba
1 changed files with 6 additions and 3 deletions
|
|
@ -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()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue