@@ -142,52 +142,47 @@ func (ix *Indexer) Status() (bool, common.Range[uint64]) {
142142// Note that this function also resumes the storage layer background process if
143143// it was previously suspended.
144144// AddBlockData implements core.Indexer.
145- func (ix * Indexer ) AddBlockData (headers [] * types.Header , receipts [] types.Receipts ) (ready bool , needBlocks common.Range [uint64 ]) {
145+ func (ix * Indexer ) AddBlockData (header * types.Header , receipts types.Receipts ) (ready bool , needBlocks common.Range [uint64 ]) {
146146 if ix .config .Disabled {
147147 return false , common.Range [uint64 ]{}
148148 }
149- if len (headers ) == 0 {
150- return ix .Status ()
151- }
152149 ix .storage .suspendOrResume (false )
153150 if ! ix .storage .isReady () {
154151 return false , ix .needBlocks ()
155152 }
156- ix .headNumber = max (ix .headNumber , headers [len (headers )- 1 ].Number .Uint64 ())
157- for i , header := range headers {
158- number , hash := header .Number .Uint64 (), header .Hash ()
159- if number > ix .headRenderer .nextBlock {
160- ix .tryCheckpointInit (number , hash )
161- }
162- if number == ix .headRenderer .nextBlock {
163- if ix .headRenderer .checkNextHash (hash ) {
164- ix .headRenderer .addReceipts (receipts [i ])
165- firstMapIndex , finishedMaps := ix .headRenderer .addHeader (header )
166- ix .storeFinishedMaps (firstMapIndex , finishedMaps , i == len (headers )- 1 , true )
167- if number + maxCanonicalSnapshots > ix .headNumber {
168- ix .storeHeadIndexView (number , hash )
169- }
170- } else {
171- ix .headRenderer = ix .initMapBoundary (max (ix .headRenderer .renderRange .First (), 1 )- 1 , math .MaxUint32 )
153+ ix .headNumber = max (ix .headNumber , header .Number .Uint64 ())
154+ number , hash := header .Number .Uint64 (), header .Hash ()
155+ if number > ix .headRenderer .nextBlock {
156+ ix .tryCheckpointInit (number , hash )
157+ }
158+ if number == ix .headRenderer .nextBlock {
159+ if ix .headRenderer .checkNextHash (hash ) {
160+ ix .headRenderer .addReceipts (receipts )
161+ firstMapIndex , finishedMaps := ix .headRenderer .addHeader (header )
162+ ix .storeFinishedMaps (firstMapIndex , finishedMaps , true , true )
163+ if number + maxCanonicalSnapshots > ix .headNumber {
164+ ix .storeHeadIndexView (number , hash )
172165 }
173- ix . updateTailEpoch ()
174- ix .updateTailState ( )
166+ } else {
167+ ix .headRenderer = ix . initMapBoundary ( max ( ix . headRenderer . renderRange . First (), 1 ) - 1 , math . MaxUint32 )
175168 }
176- if ix .tailRenderer != nil && number == ix .tailRenderer .nextBlock {
177- if ix .tailRenderer .checkNextHash (hash ) {
178- ix .tailRenderer .addReceipts (receipts [i ])
179- firstMapIndex , finishedMaps := ix .tailRenderer .addHeader (header )
180- ix .storeFinishedMaps (firstMapIndex , finishedMaps , false , false )
181- if ix .tailRenderer .finished () {
182- ix .tailEpoch --
183- ix .tailRenderer = nil
184- ix .updateTailState ()
185- }
186- } else {
187- // Note that if there is a canonical hash mismatch at the tail epoch then we need to revert the head renderer before this point.
188- ix .headRenderer = ix .initMapBoundary (max (ix .tailRenderer .renderRange .First (), 1 )- 1 , math .MaxUint32 )
169+ ix .updateTailEpoch ()
170+ ix .updateTailState ()
171+ }
172+ if ix .tailRenderer != nil && number == ix .tailRenderer .nextBlock {
173+ if ix .tailRenderer .checkNextHash (hash ) {
174+ ix .tailRenderer .addReceipts (receipts )
175+ firstMapIndex , finishedMaps := ix .tailRenderer .addHeader (header )
176+ ix .storeFinishedMaps (firstMapIndex , finishedMaps , false , false )
177+ if ix .tailRenderer .finished () {
178+ ix .tailEpoch --
189179 ix .tailRenderer = nil
180+ ix .updateTailState ()
190181 }
182+ } else {
183+ // Note that if there is a canonical hash mismatch at the tail epoch then we need to revert the head renderer before this point.
184+ ix .headRenderer = ix .initMapBoundary (max (ix .tailRenderer .renderRange .First (), 1 )- 1 , math .MaxUint32 )
185+ ix .tailRenderer = nil
191186 }
192187 }
193188 return ix .storage .isReady (), ix .needBlocks ()
@@ -626,7 +621,9 @@ func (ix *Indexer) storeHeadIndexView(number uint64, hash common.Hash) {
626621func (ix * Indexer ) exportCheckpoints () {
627622 finalLvPtr , err := ix .storage .getBlockLvPointer (ix .finalized + 1 )
628623 if err != nil {
629- log .Error ("Error fetching log value pointer of finalized block" , "block" , ix .finalized , "error" , err )
624+ if err != ErrOutOfRange {
625+ log .Error ("Error fetching log value pointer of finalized block" , "block" , ix .finalized , "error" , err )
626+ }
630627 return
631628 }
632629 epochCount := ix .storage .params .mapEpoch (uint32 (finalLvPtr >> ix .storage .params .logValuesPerMap ))
0 commit comments