Skip to content

Commit 2ecc42e

Browse files
authored
Return when total < request page (#1766)
1 parent de72e2d commit 2ecc42e

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

bridge-history-api/internal/logic/history_logic.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,6 @@ func getTxHistoryInfoFromBridgeBatchDepositMessage(message *orm.BridgeBatchDepos
361361
func (h *HistoryLogic) getCachedTxsInfo(ctx context.Context, cacheKey string, pageNum, pageSize uint64) ([]*types.TxHistoryInfo, uint64, bool, error) {
362362
start := int64((pageNum - 1) * pageSize)
363363
end := start + int64(pageSize) - 1
364-
365364
total, err := h.redis.ZCard(ctx, cacheKey).Result()
366365
if err != nil {
367366
log.Error("failed to get zcard result", "error", err)
@@ -372,6 +371,10 @@ func (h *HistoryLogic) getCachedTxsInfo(ctx context.Context, cacheKey string, pa
372371
return nil, 0, false, nil
373372
}
374373

374+
if start >= total {
375+
return nil, 0, false, nil
376+
}
377+
375378
values, err := h.redis.ZRevRange(ctx, cacheKey, start, end).Result()
376379
if err != nil {
377380
log.Error("failed to get zrange result", "error", err)
@@ -450,5 +453,6 @@ func (h *HistoryLogic) processAndCacheTxHistoryInfo(ctx context.Context, cacheKe
450453
log.Error("cache miss after write, expect hit", "cached key", cacheKey, "page", page, "page size", pageSize, "error", err)
451454
return nil, 0, err
452455
}
456+
453457
return pagedTxs, total, nil
454458
}

common/version/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"runtime/debug"
66
)
77

8-
var tag = "v4.7.4"
8+
var tag = "v4.7.5"
99

1010
var commit = func() string {
1111
if info, ok := debug.ReadBuildInfo(); ok {

0 commit comments

Comments
 (0)