mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 14:46:42 +00:00
fix txindexer panic
This commit is contained in:
parent
f62a7e22c9
commit
d4b106c978
1 changed files with 9 additions and 5 deletions
|
|
@ -205,7 +205,8 @@ func (indexer *txIndexer) loop(chain *BlockChain) {
|
||||||
var (
|
var (
|
||||||
stop chan struct{} // Non-nil if background routine is active
|
stop chan struct{} // Non-nil if background routine is active
|
||||||
done chan struct{} // Non-nil if background routine is active
|
done chan struct{} // Non-nil if background routine is active
|
||||||
head = rawdb.ReadHeadBlock(indexer.db).NumberU64() // The latest announced chain head
|
headBlock = rawdb.ReadHeadBlock(indexer.db) // The latest announced chain head
|
||||||
|
head uint64
|
||||||
|
|
||||||
headCh = make(chan ChainHeadEvent)
|
headCh = make(chan ChainHeadEvent)
|
||||||
sub = chain.SubscribeChainHeadEvent(headCh)
|
sub = chain.SubscribeChainHeadEvent(headCh)
|
||||||
|
|
@ -213,13 +214,16 @@ func (indexer *txIndexer) loop(chain *BlockChain) {
|
||||||
defer sub.Unsubscribe()
|
defer sub.Unsubscribe()
|
||||||
|
|
||||||
// Validate the transaction indexes and repair if necessary
|
// Validate the transaction indexes and repair if necessary
|
||||||
indexer.repair(head)
|
if headBlock != nil {
|
||||||
|
indexer.repair(headBlock.NumberU64())
|
||||||
|
}
|
||||||
|
|
||||||
// Launch the initial processing if chain is not empty (head != genesis).
|
// Launch the initial processing if chain is not empty (head != genesis).
|
||||||
// This step is useful in these scenarios that chain has no progress.
|
// This step is useful in these scenarios that chain has no progress.
|
||||||
if head != 0 {
|
if headBlock != nil && headBlock.NumberU64() != 0 {
|
||||||
stop = make(chan struct{})
|
stop = make(chan struct{})
|
||||||
done = make(chan struct{})
|
done = make(chan struct{})
|
||||||
|
head = headBlock.Number().Uint64()
|
||||||
go indexer.run(head, stop, done)
|
go indexer.run(head, stop, done)
|
||||||
}
|
}
|
||||||
for {
|
for {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue