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

api/epochs: Skip 'end_height' for latest epoch #709

Merged
merged 1 commit into from
Jun 19, 2024
Merged

Conversation

ptrus
Copy link
Member

@ptrus ptrus commented Jun 17, 2024

The /consensus/epochs/<latest_epoch> endpoint for the currently active epoch returns the ever increasing 'end_height'.
This is inconsistent with the API spec and also with the /consensus/epochs. Skip returning the end_height for the latest epoch.

For /consensus/epochs we already do this.

@ptrus ptrus force-pushed the ptrus/fix/latest-epoch branch 3 times, most recently from 9926c16 to 063b77c Compare June 17, 2024 13:31
Copy link
Contributor

@mitjat mitjat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thanks!

@@ -257,7 +257,8 @@ const (
OFFSET $2::bigint`

Epoch = `
SELECT id, start_height, end_height
SELECT id, start_height,
(CASE id WHEN (SELECT max(id) FROM chain.epochs) THEN NULL ELSE end_height END) AS end_height
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional:
To simplify the code and bring it more in line with other similar queries, we could abandon the Epoch SQL query and instead expand Epochs with WHERE ($1::bigint IS NULL OR $1::bigint = id).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated 👍

@ptrus ptrus force-pushed the ptrus/fix/latest-epoch branch from 063b77c to b368055 Compare June 19, 2024 07:25
@ptrus ptrus merged commit 038415b into main Jun 19, 2024
16 checks passed
@ptrus ptrus deleted the ptrus/fix/latest-epoch branch June 19, 2024 07:30
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

Successfully merging this pull request may close these issues.

2 participants