Skip to content

Add rages check on export page #975

@Viterbo

Description

@Viterbo

Overview

Add the four range checks that the indexer performs for the export endpoint and prevent the user from exporting if they are not met.

Fixed here: #1001

Indexer checks are here:
https://github.com/telosnetwork/teloscan-indexer/blob/master/src/main/java/net/telos/indexer/api/resource/ExportResource.java#L57-L78

protected void validateRanges(Long blockStart, Long blockEnd, Long timestampStart, Long timestampEnd) throws BadRequestException {
    boolean hasCompleteBlockRange = isCompleteRange(blockStart, blockEnd);
    boolean hasCompleteTimestampRange = isCompleteRange(timestampStart, timestampEnd);
    boolean hasPartialBlockRange = isPartialRange(blockStart, blockEnd);
    boolean hasPartialTimestampRange = isPartialRange(timestampStart, timestampEnd);

    if (!hasCompleteBlockRange && !hasCompleteTimestampRange) {
        throw new BadRequestException("Need either a complete block range or a complete timestamp range to export transactions.");
    }

    if (hasPartialBlockRange && hasPartialTimestampRange) {
        throw new BadRequestException("Cannot have both block and timestamp ranges.");
    }

    if (hasCompleteBlockRange && blockEnd - blockStart > ONE_YEAR_BLOCKS) {
        throw new BadRequestException("Block range must be less than " + ONE_YEAR_BLOCKS + " blocks.");
    }

    if (hasCompleteTimestampRange && timestampEnd - timestampStart > ONE_YEAR_MS) {
        throw new BadRequestException("Timestamp range must be less than one year.");
    }
}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions