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

Gh 4133 contract code endpoint and HTTP refactoring #4156

Open
wants to merge 35 commits into
base: master
Choose a base branch
from

Conversation

zxq9
Copy link
Contributor

@zxq9 zxq9 commented Jun 20, 2023

No description provided.

@@ -0,0 +1,7 @@
@title AE API: The tiny JSON encoder/decoder
Copy link
Member

Choose a reason for hiding this comment

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

??


blockchain_name() ->
<<"aeternity">>. %% TODO: check hardcoding
%% TODO: Check whether this should be hardcoded or retrieved from settings (?)
<<"aeternity">>.
Copy link
Member

Choose a reason for hiding this comment

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

What is the difference between blockchain_name() and network_id()?

Comment on lines +154 to +156
case aec_chain:top_block() of
undefined -> error;
Block -> {ok, aec_blocks:height(Block)}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
case aec_chain:top_block() of
undefined -> error;
Block -> {ok, aec_blocks:height(Block)}
case aec_chain:dirty_top_header() of
undefined -> error;
Hdr -> {ok, aec_headers:height(Block)}

Copy link
Member

Choose a reason for hiding this comment

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

aec_chain:top_block() also fetches all included transactions.

Comment on lines +176 to +179
case aec_chain:top_block() of
undefined -> error;
Block -> {ok, aec_blocks:to_header(Block)}
end.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
case aec_chain:top_block() of
undefined -> error;
Block -> {ok, aec_blocks:to_header(Block)}
end.
case aec_chain:top_header() of
undefined -> error;
Hdr -> {ok, Hdr}
end.

Comment on lines +205 to +209
top_key_block_header() ->
case aec_chain:top_key_block() of
{ok, Block} -> {ok, aec_blocks:to_header(Block)};
error -> error
end.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
top_key_block_header() ->
case aec_chain:top_key_block() of
{ok, Block} -> {ok, aec_blocks:to_header(Block)};
error -> error
end.
top_key_block_header() ->
aec_db:ensure_activity(async_dirty, fun top_key_block_header_/0).
top_key_block_header_() ->
case aec_chain:top_header() of
undefined -> error;
Header ->
case aec_headers:type(Header) of
micro ->
Hash = aec_headers:prev_key_hash(Header),
{ok, _} = aec_chain:get_header(Hash);
key ->
{ok, Header}
end
end.

Comment on lines +259 to +263
key_block_header_at_height(Height) when is_integer(Height) ->
case key_block_at_height(Height) of
{ok, Block} -> {ok, aec_blocks:to_header(Block)};
Error -> Error
end.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
key_block_header_at_height(Height) when is_integer(Height) ->
case key_block_at_height(Height) of
{ok, Block} -> {ok, aec_blocks:to_header(Block)};
Error -> Error
end.
key_block_header_at_height(Height) when is_integer(Height) ->
case aec_chain:get_key_header_by_height(Height) of
{ok, _} = Ok -> Ok;
{error, _} = Error -> Error
end.

PrevBlockHash = aec_blocks:prev_key_hash(Block),
aec_chain:get_block(PrevBlockHash);
true ->
{ok, Block}
Copy link
Member

Choose a reason for hiding this comment

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

Really??

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.

None yet

2 participants