@@ -361,7 +361,6 @@ func getTxHistoryInfoFromBridgeBatchDepositMessage(message *orm.BridgeBatchDepos
361361func (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}
0 commit comments