Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion core/txindexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ type txIndexer struct {
// newTxIndexer initializes the transaction indexer.
func newTxIndexer(limit uint64, chain *BlockChain) *txIndexer {
cutoff, _ := chain.HistoryPruningCutoff()
// If the database has a higher cutoff (due to ancient pruning), adjust the cutoff accordingly.
if dbTail, err := chain.db.Tail(); err == nil {
cutoff = max(cutoff, dbTail)
}
indexer := &txIndexer{
limit: limit,
cutoff: cutoff,
Expand Down Expand Up @@ -315,7 +319,12 @@ func (indexer *txIndexer) report(head uint64, tail *uint64) TxIndexProgress {
if indexer.limit == 0 || total > head {
total = head + 1 // genesis included
}
length := head - indexer.cutoff + 1 // all available chain for indexing
cutoff := indexer.cutoff
// If the database has a higher cutoff (due to ancient pruning), adjust the cutoff accordingly.
if dbTail, err := indexer.db.Tail(); err == nil {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with this change.
But I think we can also set cutoff in L71 — that way the log will be printed, and we can see what the cutoff is changed to.

cutoff = max(cutoff, dbTail)
}
length := head - cutoff + 1 // all available chain for indexing
if total > length {
total = length
}
Expand Down