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

TryRemoveLastFilterIfNewerThanAsync should not throw #12778

Merged
merged 2 commits into from Apr 10, 2024

Conversation

turbolay
Copy link
Collaborator

@turbolay turbolay commented Apr 8, 2024

Try implies that the function doesn't throw
RemoveAllNewerThanAsync uses it as if it was not throwing (otherwise, how can it return null???)

It's the problem here: #12400 (comment)

adamPetho
adamPetho previously approved these changes Apr 8, 2024
Copy link
Collaborator

@adamPetho adamPetho left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -317,14 +317,14 @@ public async Task<FilterModel[]> FetchBatchAsync(uint fromHeight, int batchSize,
{
if (!IndexStorage.TryRemoveLast(out filter))
{
throw new InvalidOperationException("No last filter.");
return null;
Copy link
Collaborator

@kiminuo kiminuo Apr 8, 2024

Choose a reason for hiding this comment

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

So this is important when there are no blocks in the database, right?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think there was some history about why we throw the exception but I can't recall why we did it and given the method's name and what it does I would expect the method NOT to throw, so I think it's a good change.

Copy link
Collaborator

@kiminuo kiminuo left a comment

Choose a reason for hiding this comment

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

Looks good. I just added a simple test.

@turbolay turbolay merged commit baaab5e into zkSNACKs:master Apr 10, 2024
8 checks passed
@turbolay
Copy link
Collaborator Author

turbolay commented Apr 10, 2024

I merged this because it cannot change anything in the current behaviour, but it makes the usage consistent with what can happen.

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.

None yet

3 participants