Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rages check on export page #975

Open
Viterbo opened this issue Feb 7, 2025 · 0 comments
Open

Add rages check on export page #975

Viterbo opened this issue Feb 7, 2025 · 0 comments
Assignees

Comments

@Viterbo
Copy link
Collaborator

Viterbo commented Feb 7, 2025

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.");
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

1 participant