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

fix sub-query by block height #275

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/arweave/src/ar_http_iface_middleware.erl
Expand Up @@ -1697,7 +1697,7 @@ search_in_block_index(H, BI) ->
%% @doc Find a block, given a type and a specifier.
find_block(<<"height">>, RawHeight) ->
BI = ar_node:get_block_index(whereis(http_entrypoint_node)),
ar_storage:read_block(binary_to_integer(RawHeight), BI);
ar_storage:read_block(RawHeight, BI);
Copy link
Member

Choose a reason for hiding this comment

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

Hey @goomario, thank you for looking into it.

This way if you ask for /height/2, it will search for a block with the hash <<"2">>, we need to do smth like this here instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe use this:

find_block(<<"height">>, RawHeight) when is_integer(RawHeight) ->
	BI = ar_node:get_block_index(whereis(http_entrypoint_node)),
	ar_storage:read_block(RawHeight, BI);
find_block(<<"height">>, RawHeight) ->
	BI = ar_node:get_block_index(whereis(http_entrypoint_node)),
	ar_storage:read_block(binary_to_integer(RawHeight), BI);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's work fine, I tested.

Copy link
Member

Choose a reason for hiding this comment

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

find_block(<<"height">>, RawHeight) when is_integer(RawHeight) -> - this should never match as RawHeight is a binary.

find_block(<<"hash">>, ID) ->
ar_storage:read_block(ID).

Expand Down