Skip to content

Commit ee52a06

Browse files
pingshuijieptrus
authored andcommitted
feat: use the built-in max/min to simplify the code
Signed-off-by: pingshuijie <pingshuijie@outlook.com>
1 parent 21e8163 commit ee52a06

File tree

2 files changed

+2
-9
lines changed

2 files changed

+2
-9
lines changed

db/migrations/20220109122505_logs.up.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,7 @@ func LogsUp(ctx context.Context, tx *bun.Tx) error {
165165

166166
for i := start; i <= end; i += batchSize {
167167
bs := i
168-
be := i + batchSize - 1
169-
if be > end {
170-
be = end
171-
}
168+
be := min(i+batchSize-1, end)
172169

173170
logger.Debug("migrating batch", "batch_start", bs, "batch_end", be)
174171
// Fetch all logs for the batch rounds.

rpc/eth/api.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -185,11 +185,7 @@ func (api *publicAPI) roundParamFromBlockNum(ctx context.Context, logger *loggin
185185
logger.Error("failed to get last retained block from indexer", "err", err)
186186
return 0, ErrInternalError
187187
}
188-
if clrBlk.Header.Round < ilrRound {
189-
earliest = ilrRound
190-
} else {
191-
earliest = clrBlk.Header.Round
192-
}
188+
earliest = max(clrBlk.Header.Round, ilrRound)
193189
return earliest, nil
194190
default:
195191
if int64(blockNum) < 0 {

0 commit comments

Comments
 (0)