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

feat: query channel reserve at a hash #1106

Merged
merged 2 commits into from Jan 4, 2023
Merged

Conversation

jyeshe
Copy link
Member

@jyeshe jyeshe commented Jan 4, 2023

Closes #1105
Refs #1032

@jyeshe jyeshe self-assigned this Jan 4, 2023
end

defp get_block_index(state, param_block_hash) do
block_hash = Validate.id!(param_block_hash)
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps we can send the decoded block_hash binary to avoid decoding it twice

Copy link
Member Author

Choose a reason for hiding this comment

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

It was avoiding an additional parameter since the type is also needed and it's a few microseconds operation but did the optimization though.

with {:ok, channel_pk} <- Validate.id(id, [:channel]),
{:ok, channel} <- Channels.fetch_channel(state, channel_pk) do
true <- valid_optional_block_hash?(block_hash),
Copy link
Contributor

Choose a reason for hiding this comment

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

This is the first decoding that we do, we can use its value by returning {:ok, block_hash}. In addition, if the parameter is not a valid block_hash the whole function returns false which is not handled by the FallbackController and it returns a 500 error

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@jyeshe jyeshe requested a review from sborrazas January 4, 2023 15:27
@jyeshe jyeshe merged commit e595f0b into master Jan 4, 2023
@jyeshe jyeshe deleted the channel-reserve-at-block branch January 4, 2023 16:48
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.

Query state channel reserve
3 participants