Skip to content

Commit dad9049

Browse files
authored
Merge pull request #8226 from onflow/leo/indexer-remove-redudant-header-reads
[Access] Indexer remove redundant header reads
2 parents ae3e371 + 034700c commit dad9049

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

module/state_synchronization/indexer/indexer.go

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -158,17 +158,22 @@ func (i *Indexer) onBlockIndexed() error {
158158
highestIndexedHeight := i.jobConsumer.LastProcessedIndex()
159159

160160
if lastProcessedHeight < highestIndexedHeight {
161+
if lastProcessedHeight+1000 < highestIndexedHeight {
162+
i.log.Warn().Msgf("notifying processed heights from %d to %d", lastProcessedHeight+1, highestIndexedHeight)
163+
}
161164
// we need loop here because it's possible for a height to be missed here,
162165
// we should guarantee all heights are processed
163166
for height := lastProcessedHeight + 1; height <= highestIndexedHeight; height++ {
164-
header, err := i.indexer.headers.ByHeight(height)
165-
if err != nil {
166-
// if the execution data is available, the block must be locally finalized
167-
i.log.Error().Err(err).Msgf("could not get header for height %d:", height)
168-
return fmt.Errorf("could not get header for height %d: %w", height, err)
169-
}
170-
171-
i.OnBlockProcessed(header.Height)
167+
// Use BlockIDByHeight instead of ByHeight since we only need to verify the block exists
168+
// and don't need the full header data. This avoids expensive header deserialization.
169+
// _, err := i.indexer.headers.BlockIDByHeight(height)
170+
// if err != nil {
171+
// // if the execution data is available, the block must be locally finalized
172+
// i.log.Error().Err(err).Msgf("could not get header for height %d:", height)
173+
// return fmt.Errorf("could not get header for height %d: %w", height, err)
174+
// }
175+
176+
i.OnBlockProcessed(height)
172177
}
173178
i.lastProcessedHeight.Store(highestIndexedHeight)
174179
}

0 commit comments

Comments
 (0)