Skip to content
This repository has been archived by the owner on Mar 5, 2024. It is now read-only.

Add blockchain_txn:is_valid #94

Merged
merged 2 commits into from
Apr 16, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion src/transactions/blockchain_txn.erl
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
serialize/1,
deserialize/1,
wrap_txn/1,
unwrap_txn/1
unwrap_txn/1,
is_valid/2
]).

-ifdef(TEST).
Expand Down Expand Up @@ -200,6 +201,22 @@ absorb(Txn, Chain) ->
What:Why:Stack ->
{error, {Type, What, {Why, Stack}}}
end.

%%--------------------------------------------------------------------
%% @doc
%% @end
%%--------------------------------------------------------------------
-spec is_valid(txn(), blockchain:blockchain()) -> ok | {error, any()}.
is_valid(Txn, Chain) ->
Type = ?MODULE:type(Txn),
try Type:is_valid(Txn, Chain) of
Res ->
Res
catch
What:Why:Stack ->
{error, {Type, What, {Why, Stack}}}
end.

%%--------------------------------------------------------------------
%% @doc
%% @end
Expand Down