-
Notifications
You must be signed in to change notification settings - Fork 10
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
Conversation
lib/ae_mdw/channels.ex
Outdated
end | ||
|
||
defp get_block_index(state, param_block_hash) do | ||
block_hash = Validate.id!(param_block_hash) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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), |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Closes #1105
Refs #1032