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

"readability"fix(store): Clearer range check #227

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

renaynay
Copy link
Member

@renaynay renaynay commented Oct 23, 2024

This PR cleans up a sanity check on the range request in the private method of store to make it more readable.

walldiss
walldiss previously approved these changes Oct 23, 2024
@cristaloleg
Copy link
Contributor

Can you add following lines to the TestStore in store/store_test.go ?

	out, err = store.getRangeByHeight(ctx, 10, 11)
	require.NoError(t, err)
	assert.Len(t, out, 1)

(at the end of the test, to prevent any regressions in the future)

cristaloleg
cristaloleg previously approved these changes Oct 24, 2024
Copy link
Contributor

@cristaloleg cristaloleg left a comment

Choose a reason for hiding this comment

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

LGTM but see comment regarding a few asserts

@renaynay renaynay dismissed stale reviews from cristaloleg and walldiss via 241f705 October 24, 2024 14:28
@renaynay renaynay changed the title fix(store): Allow a range of amount 1 to be requested from the store "readability"fix(store): Clearer range check Oct 24, 2024
Copy link
Contributor

@cristaloleg cristaloleg left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

// `from` with `to-1`
if from > to-1 {
return nil, fmt.Errorf("header/store: invalid range(%d,%d)", from, to-1)
if from >= to {
Copy link
Member

Choose a reason for hiding this comment

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

Did we check this on Exchange?

Copy link
Member

@walldiss walldiss left a comment

Choose a reason for hiding this comment

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

from > to-1 is the same as from >= to, but it's tricky to understand. The new version is much easier to follow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants