Skip to content

Commit 3a69e43

Browse files
authored
refactor: use the built-in max/min to simplify the code (#3577)
Signed-off-by: studystill <[email protected]>
1 parent b6e42bc commit 3a69e43

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

eth/blockwatch/block_watcher.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -433,10 +433,7 @@ func (w *Watcher) getSubBlockRanges(from, to, rangeSize int) []*blockRange {
433433

434434
for i := 0; i < numChunks; i = i + 1 {
435435
fromIndex := i * rangeSize
436-
toIndex := fromIndex + rangeSize
437-
if toIndex > len(blocks) {
438-
toIndex = len(blocks)
439-
}
436+
toIndex := min(fromIndex+rangeSize, len(blocks))
440437
bs := blocks[fromIndex:toIndex]
441438
blockRange := &blockRange{
442439
FromBlock: bs[0],

0 commit comments

Comments
 (0)