Skip to content

Commit

Permalink
use customize error
Browse files Browse the repository at this point in the history
  • Loading branch information
mask-pp committed Jan 15, 2025
1 parent 3945f60 commit 2ed17c3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
10 changes: 5 additions & 5 deletions packages/taiko-client/pkg/chain_iterator/block_batch_iterator.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"errors"
"fmt"
"io"
"math/big"
"time"

Expand All @@ -23,6 +22,7 @@ const (
)

var (
errEOF = errors.New("EOF")
errContinue = errors.New("continue")
)

Expand Down Expand Up @@ -143,7 +143,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,
Expand Down Expand Up @@ -205,7 +205,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
Expand All @@ -226,7 +226,7 @@ func (i *BlockBatchIterator) iter() (err error) {
}

if i.isEnd {
return io.EOF
return errEOF
}

i.current = endHeader
Expand All @@ -235,7 +235,7 @@ func (i *BlockBatchIterator) iter() (err error) {
return errContinue
}

return io.EOF
return errEOF
}

// updateCurrent updates the iterator's current cursor.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package chainiterator

import (
"context"
"io"
"math/big"
"testing"
"time"
Expand Down Expand Up @@ -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)
}

Expand Down

0 comments on commit 2ed17c3

Please sign in to comment.