Skip to content

Commit

Permalink
Change debug tx in mempool endpoint to use dry run
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchelli committed Apr 8, 2024
1 parent de34e33 commit c40ded8
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions apps/aehttp/src/aehttp_dispatch_int.erl
Original file line number Diff line number Diff line change
Expand Up @@ -277,14 +277,15 @@ handle_request_('GetCheckTxInPool', Req, _Context) ->
{BlockHash, _Tx} when is_binary(BlockHash) ->
{ok, {200, [], #{<<"status">> => <<"included">>}}};
{mempool, SignedTx} ->
{Env, Trees} = aetx_env:tx_env_and_trees_from_top(aetx_transaction),
Env1 = aetx_env:set_signed_tx(Env, {value, SignedTx}),
Tx = aetx_sign:tx(SignedTx),
try aetx:process(Tx, Trees, Env1) of
{ok, _Trees1, _Env20} ->
try aec_dry_run:dry_run(top, [], [{tx, Tx}], [{tx_events, false}]) of
{ok, {[{_Type,ok}], _Events}} ->
{ok, {200, [], #{<<"status">> => <<"includable">>}}};
{ok, {[{_Type,{error, Reason}}], _Events}} ->
{ok, {200, [], #{<<"status">> => atom_to_binary(Reason, utf8)}}};
{error, Reason} ->
{ok, {200, [], #{<<"status">> => atom_to_binary(Reason, utf8)}}}
lager:error("HTTP API: tx ~p cannot be applied due to an error ~p", [Tx, Reason]),
{ok, {200, [], #{<<"status">> => <<"unhandled">>}}}
catch
Type:What ->
Reason = {Type, What},
Expand Down

0 comments on commit c40ded8

Please sign in to comment.