diff --git a/packages/taiko-client/pkg/chain_iterator/block_batch_iterator.go b/packages/taiko-client/pkg/chain_iterator/block_batch_iterator.go index 994574c2adb..c531cb77fc7 100644 --- a/packages/taiko-client/pkg/chain_iterator/block_batch_iterator.go +++ b/packages/taiko-client/pkg/chain_iterator/block_batch_iterator.go @@ -4,7 +4,6 @@ import ( "context" "errors" "fmt" - "io" "math/big" "time" @@ -24,6 +23,7 @@ const ( ) var ( + errEOF = errors.New("end of blockBatchIterator batch") errContinue = errors.New("continue") ) @@ -144,7 +144,7 @@ func (i *BlockBatchIterator) Iter() error { break } if err := i.iter(); err != nil { - if errors.Is(err, io.EOF) { + if errors.Is(err, errEOF) { log.Debug( "Block batch iterator finished", "start", i.startHeight, @@ -212,7 +212,7 @@ func (i *BlockBatchIterator) iter() (err error) { } if i.current.Number.Uint64() >= destHeight { - return io.EOF + return errEOF } endHeight = i.current.Number.Uint64() + i.blocksReadPerEpoch @@ -233,7 +233,7 @@ func (i *BlockBatchIterator) iter() (err error) { } if i.isEnd { - return io.EOF + return errEOF } i.current = endHeader @@ -242,7 +242,7 @@ func (i *BlockBatchIterator) iter() (err error) { return errContinue } - return io.EOF + return errEOF } // updateCurrent updates the iterator's current cursor. diff --git a/packages/taiko-client/pkg/chain_iterator/block_batch_iterator_test.go b/packages/taiko-client/pkg/chain_iterator/block_batch_iterator_test.go index 429505c4bd1..5886dab291e 100644 --- a/packages/taiko-client/pkg/chain_iterator/block_batch_iterator_test.go +++ b/packages/taiko-client/pkg/chain_iterator/block_batch_iterator_test.go @@ -2,7 +2,6 @@ package chainiterator import ( "context" - "io" "math/big" "testing" "time" @@ -110,7 +109,7 @@ func (s *BlockBatchIteratorTestSuite) TestIterWithLessThanConfirmations() { }) s.Nil(err) - s.Equal(io.EOF, iter.iter()) + s.Equal(errEOF, iter.iter()) s.Equal(headHeight, lastEnd) }