diff --git a/api/coreservice.go b/api/coreservice.go index efcfae7103..ee93191af8 100644 --- a/api/coreservice.go +++ b/api/coreservice.go @@ -1401,12 +1401,6 @@ func (core *coreService) LogsInRange(filter *logfilter.LogFilter, start, end, pa if err != nil { return nil, nil, err } - if paginationSize == 0 { - paginationSize = 1000 - } - if paginationSize > 5000 { - paginationSize = 5000 - } // getLogs via range Blooom filter [start, end] blockNumbers, err := core.bfIndexer.FilterBlocksInRange(filter, start, end, paginationSize) if err != nil { @@ -1461,7 +1455,7 @@ func (core *coreService) LogsInRange(filter *logfilter.LogFilter, start, end, pa for j := range logsInBlk[i] { logs = append(logs, logsInBlk[i][j]) hashes = append(hashes, HashInBlk[i]) - if len(logs) >= int(paginationSize) { + if paginationSize > 0 && len(logs) >= int(paginationSize) { return logs, hashes, nil } } @@ -1471,20 +1465,24 @@ func (core *coreService) LogsInRange(filter *logfilter.LogFilter, start, end, pa } func (core *coreService) correctQueryRange(start, end uint64) (uint64, uint64, error) { + bfTipHeight, err := core.bfIndexer.Height() + if err != nil { + return 0, 0, err + } if start == 0 { - start = core.bc.TipHeight() + start = bfTipHeight } if end == 0 { - end = core.bc.TipHeight() + end = bfTipHeight } if start > end { return 0, 0, errors.New("invalid start or end height") } - if start > core.bc.TipHeight() { + if start > bfTipHeight { return 0, 0, errors.New("start block > tip height") } - if end > core.bc.TipHeight() { - end = core.bc.TipHeight() + if end > bfTipHeight { + end = bfTipHeight } return start, end, nil }