forked from cerc-io/plugeth
core/rawdb: fix the transaction indexer (#22395)
This commit is contained in:
parent
d96870428f
commit
19d7a37abb
@ -243,13 +243,13 @@ func indexTransactions(db ethdb.Database, from uint64, to uint64, interrupt chan
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// If there exists uncommitted data, flush them.
|
// Flush the new indexing tail and the last committed data. It can also happen
|
||||||
if batch.ValueSize() > 0 {
|
// that the last batch is empty because nothing to index, but the tail has to
|
||||||
WriteTxIndexTail(batch, lastNum) // Also write the tail there
|
// be flushed anyway.
|
||||||
if err := batch.Write(); err != nil {
|
WriteTxIndexTail(batch, lastNum)
|
||||||
log.Crit("Failed writing batch to db", "error", err)
|
if err := batch.Write(); err != nil {
|
||||||
return
|
log.Crit("Failed writing batch to db", "error", err)
|
||||||
}
|
return
|
||||||
}
|
}
|
||||||
select {
|
select {
|
||||||
case <-interrupt:
|
case <-interrupt:
|
||||||
@ -334,13 +334,13 @@ func unindexTransactions(db ethdb.Database, from uint64, to uint64, interrupt ch
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Commit the last batch if there exists uncommitted data
|
// Flush the new indexing tail and the last committed data. It can also happen
|
||||||
if batch.ValueSize() > 0 {
|
// that the last batch is empty because nothing to unindex, but the tail has to
|
||||||
WriteTxIndexTail(batch, nextNum)
|
// be flushed anyway.
|
||||||
if err := batch.Write(); err != nil {
|
WriteTxIndexTail(batch, nextNum)
|
||||||
log.Crit("Failed writing batch to db", "error", err)
|
if err := batch.Write(); err != nil {
|
||||||
return
|
log.Crit("Failed writing batch to db", "error", err)
|
||||||
}
|
return
|
||||||
}
|
}
|
||||||
select {
|
select {
|
||||||
case <-interrupt:
|
case <-interrupt:
|
||||||
|
Loading…
Reference in New Issue
Block a user